Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP and page titles

adding titles to dynamic pages



11:34 am on Jan 31, 2006 (gmt 0)

10+ Year Member


Does anyone know how to assign unique titles to html pages that are dynamically created through php?

The problem Iím having is that although the pages on my site have html extensions when loaded in the browser they are not present on my server, this must mean that they are generated dynamically.. right? For this reason I am unable to assign unique titles to each page.

Iím new to php so this is extremely confusing, can anyone please shed some light.

Many thanks in advance.



12:24 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Is this your site? Why do you not know how your pages are generated? Maybe you are using a cms.
Personally I just call a variable into the page title.
I then define the variable within one of my includes.
This may work for you but its hard to say since I do not know how the pages are generated. Do you have header and footer includes?


2:57 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Many thanks Neo,

No, this isn't my site and I'm not a programmer unfortunaltely.. I just know HTML.

There are no headers or footers on the pages, in fact the only pages that exist on the server are php pages with no html in them... i'm just not sure where the .html pages are genereted... it's all blowing my mind!

Thanks again, Lee


5:48 pm on Jan 31, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

>> it's all blowing my mind

well try not to hurt yourself ;)

ok, so we have some unknown software or script that is generating the pages. Any clue as to what software it might be? If not you can still find where the titles are.

Try seeing if there are any scripts called Template or something.

also, how do you add content to the site?


5:56 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Ohhh. Well I would guess that the pages are actually php pages but use an html ext and your server is set to parse pages with html extensions as php. Just a guess mind you. Im far from an expert with this sort of thing.
You say the php pages have no html content at all? Now this is where you lose me I am afraid.
I would have thought they would either need some html within them, use an include or query a database, though to query a database from actual html code sounds crazy to me.
Can you paste any of the code in here? Obviously with any sensitive data/information removed.


6:05 pm on Jan 31, 2006 (gmt 0)

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You will probably have a .htaccess file in the same directory as the index page (may be 'hidden' - try typing the name into your FTP open box and pressing ok).

If you see lines something like:
RewriteRule ^(.*?)page.html$ showpage.php?page=$1

Then the system is using the script you see on the right of the RewriteRule (in this case, showpage.php).

If you don't see these lines, look for:
ErrorDocument 404 somescript.php

The the system is using a '404-trick' to serve the pages. Read the file named as the script on the right of the line (in this case, somescript.php).

In both cases, my best guess is that all pages are held in a database, and headers and footers are held in separate files (look for a templates directory or files named header.php or footer.php).

The database may not have a TITLE field in it - if not - add one. You then need to modify the script you found to load the files, and output them.


6:05 pm on Jan 31, 2006 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

basically the pages are being created 'on the fly' from data in a database.

usually you would have a database field which would be used to create the page title OR it would be created using a standard phrase plus some keywords from the database.

when the data is entered there should be a way of entering a title for the page.

perhaps not ... in which case there are ways to do it from the other data in the data base


6:31 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Thanks again for your time guys!

There are many template files all with .tpl extensions.

Heres the code for catolgue.php page; If you navigate from the website you access the catologue.html page but this page does not exist on the server.



/* Breadcrumb Display */
$breadcrumb_names = array('Home','Catalogue');
$breadcrumb_urls = array('index.html','catalogue.html');

/* Meta Tags */
list($keywords,$description,$title) = MetaKeywords::GetMetaKeywords('catalogue_choice');

$fastMoverChart = new FastMoverChart();

$coolCutsCharts = CoolCutsCharts::FindAll();

$letters = array('0','A','B','C','D','E','F','G',

//Last updated date for catalogues
$db =& Registry::GetDBConnection();
$newUpdated = SqlUtilities::GetTableLastUpdated(&$db,'products');
$secondHandUpdated = SqlUtilities::GetTableLastUpdated(&$db,'secondh');



Any ideas?


6:48 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

my guess is you are indeed using a CMS, based on Smarty [smarty.php.net]


7:10 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Many thanks Vince & others,

There is a rewrite rule so guess you've solved the problem of the elusive .html files! There is also a header.php file.

So what I need to do is;

> Add TITLE field to database
> Amend the header.php file to output these new fields to the pages

Guess now all I need is someone to do it for me.. for a price of course!

Cheers to all you guys, at least now I know what I need to do