homepage Welcome to WebmasterWorld Guest from 54.196.225.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php include in template page
wont work
htdawg




msg:3657205
 10:04 am on May 23, 2008 (gmt 0)

hi
I downloaded a free link directory script and modified the template
layout for my site. the script is in a folder e.g www.mysite.com/dir/

and I want to include the footer for all the pages in the /dir/ folder

I tried adding a include e.g <?php include("includes/footer.php"); ?>

and it wont show up but when I view source from the browser i can see the include code on the page (<?php include("includes/footer.php"); ?>)

I thought that you cant see php code if you view source from the browser.

does that mean there is somthing else to do to use a php include?

thanks

 

barns101




msg:3657264
 11:31 am on May 23, 2008 (gmt 0)

It sounds like the page that you've inserted the PHP code into isn't getting parsed. Does it have the .php extension?

htdawg




msg:3657292
 11:57 am on May 23, 2008 (gmt 0)

the page has a php extention e.g template.php and from what I understand whatever I change on that page shows up on the index.php page
only the include does not work. about not being parsed what do you do for that? as I said before when i view the pages source code from the browser it shows the include code. is that what you mean by not being parsed?

thanks

Pico_Train




msg:3657321
 12:28 pm on May 23, 2008 (gmt 0)

yes, definetely not parsed.

Put a <?php echo "hello mom";?> at the top of the page to confirm and see if it shows when you view it or if the code just sits there.

[edited by: Pico_Train at 12:29 pm (utc) on May 23, 2008]

htdawg




msg:3657327
 12:47 pm on May 23, 2008 (gmt 0)

well I tried <?php echo "hello mom";?> and it didn't show up on the page

but I could see it when I viewed the source code. so if it wont parse how do you fix that?

thanks

russkern




msg:3657340
 12:57 pm on May 23, 2008 (gmt 0)

What is the file name? it should be something like "filename.php"

Also... your server is set up to use PHP.. correct?

htdawg




msg:3657356
 1:19 pm on May 23, 2008 (gmt 0)

the file is <?php include("includes/footer.php"); ?>

and I am calling it from a folder e.g www.mysite.com/includes/footer.php

and I want the contents of footer.php to show up on my page which is in

www.mysite.com/dir/index.php

the thing is that the /dir/index.php page calls the layout of the page from the template.php page which I placed the include file in so that it would show up on the /dir/index.php page if i add the include directly to the /dir/index.php page it works.

any ideas?

kwasher




msg:3657378
 1:50 pm on May 23, 2008 (gmt 0)

I think...
[its more convoluted than I originally thought...]

...maybe try...

<?php include("../includes/footer.php"); ?>

russkern




msg:3657404
 2:21 pm on May 23, 2008 (gmt 0)

Or...Don't know exactly how you have things set up, but couldn't you just put your footer info in the "template.php" file and skip the footer.php include altogether?

henry0




msg:3657451
 3:20 pm on May 23, 2008 (gmt 0)

Your problem is almost certainly due to the fact that the template is called by a class
that calls a bunch of "sections"
so figure out if there is a class and what the class calls for.
you might find something like:

$content_page_name .= '';
include "../../includes/page_name.inc.php";
$page->SetParameter("PAGE_NAME",$content_page_name );

and each includes (you will need to create yours)
might look like this:
$db = new MySQL_Db;
$db->connect($host, $un, $pw);
$db->query($db_db);
$result = $db->query("
SELECT main_content
FROM #*$!#*$!
WHERE
topic_id='$topic_id'
");
while($new_content= $db->fetch_array($result))
{
$content_main_content.= $new_content['main_content'];
}

htdawg




msg:3657830
 9:48 pm on May 23, 2008 (gmt 0)


I think henry is right, I just got an email from the guy that wrote the script & he said that I have to place the include in the index.php file & not the template.php cause the index file calls each part of the directory script e.g categories ect..

only thing is that the include shows up on the page when put in the index file but not in the position that i want it. he didn't mention how to position it.

anyway thanks guys!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved