![]() |
|
![]() |
#1 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
Template Customization Using PHP Objects
I have a problem that I don't think is quite covered in all the threads I've looked at, although this thread looks like it has something close to what I'm looking for.
My web page header and footer are defined in a PHP class called Navigation. I pass a number of variables to the methods within the class, then have the following code that places header and footer, respectively, on the page: Code:
echo $Navigation->getHeader(); echo $Navigation->getFooter(); <added> For clarification, my header includes everything from the <html> tag through the <body> tag. </added> Last edited by vinyl-junkie; 02-01-2004 at 09:51 AM. |
![]() |
![]() |
![]() |
#2 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Hi. To use echo $Navigation->getHeader(); and echo $Navigation->getFooter(); perhaps try the following.
At the top of search_function.php add: PHP Code:
PHP Code:
PHP Code:
Remember to remove any "word" wrapping in the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#3 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
Something is missing, I think. Just to make sure I didn't have anything I overlooked in setting up the object oriented code, I added the following (in bold) to a section of code you told me to add:
Code:
ob_start(); require("/home/napathon/public_html/ssi/header.php"); $my_header_file = ob_get_contents(); die($my_header_file); ob_end_clean(); |
![]() |
![]() |
![]() |
#4 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Hi. Change the following:
PHP Code:
PHP Code:
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#5 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
Yes, the header displays just fine when I do that.
|
![]() |
![]() |
![]() |
#6 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Hi. In search_function.php the "ob" code is at the top, before the $t_mstrings = compact('my_header_file','my_footer_file',... part? Note that in $t_strings there are no dollar signs on the right hand side. Are you using a template that came with PhpDig, and <phpdig:my_header_file/> and <phpdig:my_footer_file/> are used in the template file? It seems like there may just be a typo somewhere as $my_header_file and $my_footer_file are holding content.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#7 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
In search_function.php, the "ob" part is the very first statements in the code, and looks like this.
Code:
ob_start(); require("/home/napathon/public_html/ssi/header.php"); $my_header_file = ob_get_contents(); ob_end_clean(); ob_start(); require("/home/napathon/public_html/ssi/footer.php"); $my_footer_file = ob_get_contents(); ob_end_clean(); Code:
if ($template == 'array' || is_file($template)) { $phpdig_version = PHPDIG_VERSION; $t_mstrings = compact('my_header_file','my_footer_file','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links'); The config.php file has this: Code:
$template = "$relative_script_path/templates/template.php"; I took a phpDig template and modified it so that the header and footer have this, respectively: Code:
<phpdig:my_header_file/> <phpdig:my_footer_file/> |
![]() |
![]() |
![]() |
#8 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Hi. Try either modifying the .../PHP_DIG/templates/template.php file so that it contains the <phpdig:my_header_file/> and <phpdig:my_footer_file/> tags or setting the $template variable in the config.php file to the PhpDig template that uses the <phpdig:my_header_file/> and <phpdig:my_footer_file/> tags. It looks like one template has the tags but another template sans tags is being used by PhpDig.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#9 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
I've messed with this for quite a while this evening, and I just don't see where the problem is. One thing I noticed is that the "else" condition of the following code is being executed, rather than the "if" condition. Is this what should happen?
Code:
if ($template == 'array' || is_file($template)) { $phpdig_version = PHPDIG_VERSION; $t_mstrings = compact('my_header_file','my_footer_file','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links'); $t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template); if ($template == 'array') { return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results)); } else { $t_strings = array_merge($t_mstrings,$t_fstrings); phpdigParseTemplate($template,$t_strings,$table_results); } } |
![]() |
![]() |
![]() |
#10 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
>> Is this what should happen?
Hi. That's okay. One thing I did notice is that if you call http://www.napathon.net/ssi/header.php and http://www.napathon.net/ssi/footer.php from the browser, the "call to a member function on a non-object" error appears.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#11 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
Well, now I'm really confused. I have all the code in search.php that sets the value of the header and footer variables, instantiates the class, etc. The only thing that is in header.php is this.
Code:
<?php echo $Navigation->getHeader(); ?> |
![]() |
![]() |
![]() |
#12 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
>> Have I completely misunderstood what I need to do in order to set this up?
Hi. Nah, I think that the header.php and footer.php files need to have access to the header-footer class/script so that echo $Navigation->getHeader(); and echo $Navigation->getFooter(); output the header and footer. Perhaps add an include("/path/to/class/script.php"); into header.php and footer.php, and then call just header.php and footer.php from the browser to check and see if the HTML is onscreen.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#13 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
Still no joy. This may be overkill but I've saved all the relevant files with .txt file extensions and uploaded them to the Web server into the same directory as their .php counterpart. Maybe this will help diagnose the problem.
http://www.napathon.net/PHP_DIG/search.txt http://www.napathon.net/ssi/header.txt http://www.napathon.net/ssi/footer.txt http://www.napathon.net/PHP_DIG/includes/config.txt http://www.napathon.net/PHP_DIG/libs...h_function.txt http://www.napathon.net/PHP_DIG/templates/template.txt |
![]() |
![]() |
![]() |
#14 |
Head Mole
Join Date: May 2003
Posts: 2,539
|
Hi. Change header.php back to the following:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension. |
![]() |
![]() |
![]() |
#15 |
Purple Mole
Join Date: Jan 2004
Posts: 694
|
It worked!
![]() Thanks again. |
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
php includes template info | 5wayshost | Coding & Tutorials | 0 | 12-31-2006 09:59 PM |
A simple include in my php template doesn't appear | claudiomet | How-to Forum | 4 | 08-23-2004 06:35 AM |
Creating a .php Template Instead of .html | Destroyer X | How-to Forum | 25 | 07-29-2004 09:53 PM |
PHP and Javascript in phpdig.html template file | jayhawk | How-to Forum | 1 | 06-17-2004 05:03 PM |
PHP includes in Template? | jirving | How-to Forum | 1 | 09-29-2003 02:37 PM |