Jump to content

page_title


anteater

Recommended Posts

Hello,

 

I am not very good at PHP. I have a header and footer include in every page. Now I want a different title for each page.

The code I inserted doesn't work. Can anyone help me?

 

Thanks in advance.

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Although what you have done is not a good way to create your page header, this should work:

 

On the first line after your "function page_header( $pict='top1.png' ) {" function declaration, add the following:

 

  global $page_title;

 

Note: This is just a hack for your code to make the page title work; as I said it's not really good coding practice.  If you want a more thorough explanation and/or example let me know.

Link to comment
Share on other sites

I usually don't like outputting my template headers from a function, maybe it's just a preference but I find it pretty messy.  What I'll do instead, is something like this:

 

in index.php:

<?
$page_title = "AntEater B.V.";
include "header.php";
?>

All my other body text

<?
include "footer.php";
?>

 

Then, in header.php you would have something like:

 

<?
$page_title = $page_title ? $page_title : 'Default Page Title';
?>
<html>
<head>
<title><?= $page_title ?></title>
....

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.