I'm using Serendipity 0.9 and PHP 4.3.2. After reading the instructions regarding embedding Serendipity into an existing template, I still am unable to have the header and footer displayed using the wrapper file method.
I have a "header.php" and a "footer.php" that I would like to include at the beginning and end of each Serendipity page (except admin).
The "embed" option is set to "yes", and the wrapper file points to wrapper.php. That's as far as I get.
I don't have a content.php as demonstrated in the instructions. The typical page on my site looks like this
<? include("http://www.domain.com/foo/header.php"); ?>
Content goes here
<? include("http://www.domain.com/foo/footer.php"); ?>
So how can I include header.php and footer.php into the Serendipity pages?
Thanks
Can't insert header/footer with wrapper file
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Can't insert header/footer with wrapper file
first off, you should NEVER use an include("http://...") call. Always only call the path for it. This is MUCH faster.
For serendipity, you have two ways. One is the wrapper.php example, but since you didn't post how your wrapper.php looks like, I can't give you suggestions on that.
The much easier way is this:
1. Edit your Serendipity template's "index.tpl" file. If you have not yet created a custom template, copy the templates/default/* folder to templates/mytemplate. In that index.tpl place those two tags:
at the places where you want them to show up.
2. Now create a config.inc.php file in your template directory with this content:
HTH,
Garvin
For serendipity, you have two ways. One is the wrapper.php example, but since you didn't post how your wrapper.php looks like, I can't give you suggestions on that.
The much easier way is this:
1. Edit your Serendipity template's "index.tpl" file. If you have not yet created a custom template, copy the templates/default/* folder to templates/mytemplate. In that index.tpl place those two tags:
Code: Select all
{$header}
{$footer}
2. Now create a config.inc.php file in your template directory with this content:
Code: Select all
<?php
// First, we get the HEADER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/foo/header.php';
$header = ob_get_contents();
ob_end_clean();
// Now, we get the FOOTER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/foo/footer. php';
$footer = ob_get_contents();
ob_end_clean();
// Now that we have $header and $footer, let's put it into our index.tpl:
$serendipity['smarty']->assign('header', $header);
$serendipity['smarty']->assign('footer', $footer);
?>
Garvin
Last edited by garvinhicking on Thu Nov 10, 2005 5:26 pm, edited 1 time in total.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
Guest
Thanks for your help... but still can't get it to work.
I copied the /templates/default folder into a new folder, and changed the index.tpl and created the config.inc.php as described. I set the embed option to "yes" and set the index file to index.php (also tried with embed option set to "no" and that did not work either.
I get a blank screen when trying to view entries. The source code looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"></HEAD>
<BODY></BODY></HTML>
So it's not printing the header, footer, or any of the blog content.
Any ideas?
I copied the /templates/default folder into a new folder, and changed the index.tpl and created the config.inc.php as described. I set the embed option to "yes" and set the index file to index.php (also tried with embed option set to "no" and that did not work either.
I get a blank screen when trying to view entries. The source code looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"></HEAD>
<BODY></BODY></HTML>
So it's not printing the header, footer, or any of the blog content.
Any ideas?
-
Guest
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
This may be caused by your header.php or footer.php script. How do they look like?
And what does your config.inc.php currently look like? If it contains parse errors, you can get the empty page you described.
You don't need to use embed mode anymore with the solution I pointed out, it would work all without embedding.
Regards,
Garvin
And what does your config.inc.php currently look like? If it contains parse errors, you can get the empty page you described.
You don't need to use embed mode anymore with the solution I pointed out, it would work all without embedding.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
Guest
The config.inc.php looks like this:
<?
// First, we get the HEADER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/home/httpd/vhosts/domain.com/httpdocs/foo/header.php';
$header = ob_get_content();
ob_end_clean();
// Now, we get the FOOTER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/home/httpd/vhosts/domain.com/httpdocs/foo/footer.php';
$footer = ob_get_content();
ob_end_clean();
// Now that we have $header and $footer, let's put it into our index.tpl:
$serendipity['smarty']->assign('header', $header);
$serendipity['smarty']->assign('footer', $footer);
?>
For the header.php and footer.php for the debugging I'm am simply using this:
<?
echo "test header";
?>
(using "test footer" for footer.php)
It only prints "test header", nothing further. No Serendipity output nor footer.
<?
// First, we get the HEADER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/home/httpd/vhosts/domain.com/httpdocs/foo/header.php';
$header = ob_get_content();
ob_end_clean();
// Now, we get the FOOTER by including it.
// The ob_* calls before it enable output buffering so that
// you can fetch the output and put it inside a variable later.
ob_start();
include '/home/httpd/vhosts/domain.com/httpdocs/foo/footer.php';
$footer = ob_get_content();
ob_end_clean();
// Now that we have $header and $footer, let's put it into our index.tpl:
$serendipity['smarty']->assign('header', $header);
$serendipity['smarty']->assign('footer', $footer);
?>
For the header.php and footer.php for the debugging I'm am simply using this:
<?
echo "test header";
?>
(using "test footer" for footer.php)
It only prints "test header", nothing further. No Serendipity output nor footer.
-
Guest
Something wierd... I put {$header} and {$footer} in my template index.tpl directory. However removing those lines still generates the same effect (blank screen after printing header), but how can it print the header at all if {$header} is missing?
index.tpl
{if $is_embedded != true}
{if $is_xhtml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{else}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
{/if}
<html>
<head>
<title>{$head_title|@default:$blogTitle} {if $head_subtitle} - {$head_subtitle}{/if}</title>
<meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />
<meta name="Powered-By" content="Serendipity v.{$head_version}" />
<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
<link rel="alternate" type="application/rss+xml" title="{$blogTitle} RSS feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/index.rss2" />
<link rel="alternate" type="application/x.atom+xml" title="{$blogTitle} Atom feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/atom.xml" />
{if $entry_id}
<link rel="pingback" href="{$serendipityBaseURL}comment.php?type=pingback&entry_id={$entry_id}" />
{/if}
{$header}
{serendipity_hookPlugin hook="frontend_header"}
</head>
<body>
{else}
{serendipity_hookPlugin hook="frontend_header"}
{/if}
{if $is_raw_mode != true}
<table id="mainpane">
<tr>
{if $leftSidebarElements > 0}
<td id="serendipityLeftSideBar" valign="top">{serendipity_printSidebar side="left"}</td>
{/if}
<td id="content" valign="top">{$CONTENT}</td>
{if $rightSidebarElements > 0}
<td id="serendipityRightSideBar" valign="top">{serendipity_printSidebar side="right"}</td>
{/if}
</tr>
</table>
{/if}
{$raw_data}
{serendipity_hookPlugin hook="frontend_footer"}
{if $is_embedded != true}
</body>
</html>
{/if}
{$footer}
index.tpl
{if $is_embedded != true}
{if $is_xhtml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{else}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
{/if}
<html>
<head>
<title>{$head_title|@default:$blogTitle} {if $head_subtitle} - {$head_subtitle}{/if}</title>
<meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />
<meta name="Powered-By" content="Serendipity v.{$head_version}" />
<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
<link rel="alternate" type="application/rss+xml" title="{$blogTitle} RSS feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/index.rss2" />
<link rel="alternate" type="application/x.atom+xml" title="{$blogTitle} Atom feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/atom.xml" />
{if $entry_id}
<link rel="pingback" href="{$serendipityBaseURL}comment.php?type=pingback&entry_id={$entry_id}" />
{/if}
{$header}
{serendipity_hookPlugin hook="frontend_header"}
</head>
<body>
{else}
{serendipity_hookPlugin hook="frontend_header"}
{/if}
{if $is_raw_mode != true}
<table id="mainpane">
<tr>
{if $leftSidebarElements > 0}
<td id="serendipityLeftSideBar" valign="top">{serendipity_printSidebar side="left"}</td>
{/if}
<td id="content" valign="top">{$CONTENT}</td>
{if $rightSidebarElements > 0}
<td id="serendipityRightSideBar" valign="top">{serendipity_printSidebar side="right"}</td>
{/if}
</tr>
</table>
{/if}
{$raw_data}
{serendipity_hookPlugin hook="frontend_footer"}
{if $is_embedded != true}
</body>
</html>
{/if}
{$footer}
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
I'm sorry, I made an error in the config.inc.php script. It must read "ob_get_contents" instead of only "ob_get_content". The latter version creates a PHP error, thus the script didn't work.
Regardsf,
Garvin
Regardsf,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
That's great! Hope you'll have fun with Serendipity! 
Regards,
Garvin
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/