Jump to content

Calling title and meta dynamically


Recommended Posts

I looked for and found a similar thread, but the resulting bunny trail was specific to that OP's situation.


I'll jump right to it.  I've seen this done on another site, and I want to implement it the same way on another site I'm doing.


Any typical page of the site will have includes files, quite a few of them nested like those little russian dolls.


For instance, the about us page calls includes/header.php...

<?php include("includes/header.php") ?>


...and the header.php file calls the meta information...

<?php include("includes/site_titles.php") ?>
<?php include("includes/site_keywords.php") ?>
<?php include("includes/site_descriptions.php") ?>


...and those files have arrays...

$SITE_TITLES = array();
$SITE_TITLES['about_us'] = $SITE_TITLE . " About Us";
$SITE_TITLES['page2'] = $SITE_TITLE . " page2";
$SITE_TITLES['page3'] = $SITE_TITLE . " page3";


...and going back to our header.php, in the appropriate place, we echo the title and meta...


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="<?php echo $SITE_DESCRIPTIONS[$page]?>" />
<meta name="keywords" content="<?php echo $SITE_KEYWORDS[$page]?>" />


...which, when uploaded, *should* display in "view source" the correct title tag, keywords, and description.


However, when I do this, I get empty tags.


Am I supposed to define the site variable ($SITE)?  Or am I doing something else wrong?  I have the original source where I first saw this  in Dreamweaver, but am unable to find a file where $SITE and all it's little buddies are defined to correspond with a file name ('about' = ("about.php").


Any help or advice is greatly appreciated.





Link to comment
Share on other sites

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.

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.