I'm probably not using the correct language but I will attempt to explain my problem.
We have not been able to figure out how to name each php file on our website in the title section so that when the page comes up it uses a different title than what is on the master template.
I don't understand php files very well and our web-design guy has not done any research to fix this problem.
Could someone look at one of our php files and see what we need to do.
Below is a sample of the section on the php file that I believe you need to look at. If not let me know what I need to show.
Thanks for the help,
Karey
//initialize an object of the class
$template=new patTemplate();
//set name of template file
$template->readTemplatesFromFile("templates/white_tmpl.html");
// set values for template variables
$template->addVar("master", "CENTER CONTENT", $content);
// set other variable values
$title=' - Feature page for “How the Right Brain Learns“';
$keyword='';
// replace placeholders with actual variable values
$template->addVar("master", "TITLE CONTENT", $title);
$template->addVar("master", "KEYWORD CONTENT", $keyword);
$template->addVar("master", "BANNER CONTENT", $banner);
// parse and display the template
$template->displayParsedTemplate("master");
Naming each php file in the title tag section
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Naming each php file in the title tag section
If you haven't migrated to a database driven CMS or created your own then it's a painful process of having every single page have a static variable set.
If you have a variable in one page but then have the template elsewhere you'll likely benefit from using a PHP class.
my_page.php
_template_title.php
A PHP class variable once set can be accessed universally unlike a regular variable. You can also assign class variables arrays and such.
However this is ultimately a vain approach as I've used file-based templates long enough to know that relational database driven CMS is so much easier, at least once you have it up and running.
If you have a variable in one page but then have the template elsewhere you'll likely benefit from using a PHP class.
my_page.php
Code: Select all
<?php
class cms{}
$cms = new cms();
$cms->set('title','page title goes here');
?>Code: Select all
<?php
echo '<title>'.$cms->title.'</title>'."\n";
?>However this is ultimately a vain approach as I've used file-based templates long enough to know that relational database driven CMS is so much easier, at least once you have it up and running.
Re: Naming each php file in the title tag section
you picked the right spot i think ( patTemplate ). have an array of titles, then call up the relevant title for each php filekarey wrote: We have not been able to figure out how to name each php file on our website in the title section so that when the page comes up it uses a different title than what is on the master template.
// set other variable values
$title=' - Feature page for “How the Right Brain Learns“';
examples...
$titles['about_us.php']="ABOUT US";
$titles[contact_us.php']="CONTACT US";
you then find the page being accessed by looking $_SERVER['QUERY_STRING'];
and then assign the titles...
something like ...
$page = extract_page($_SERVER['QUERY_STRING']); // note extract page is an abstract function you will need to make to process to query to find which page is being accessed.
and then...
$title = $titles[{$page}];
and that would be it, patTemplate will do the rest.
hope i am making sense.