homepage Welcome to WebmasterWorld Guest from 54.205.160.82
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP and page titles
adding titles to dynamic pages
UKSEOconsultant




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

Hi,

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.

Lee

 

neo_brown




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

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?

UKSEOconsultant




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

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

jatar_k




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

>> 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?

neo_brown




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

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.

vincevincevince




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

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.

topr8




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

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

UKSEOconsultant




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

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.

<?php

include('./inc/config.php');

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

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

$fastMoverChart = new FastMoverChart();
$smarty->assign('fastmover',$fastMoverChart);

$coolCutsCharts = CoolCutsCharts::FindAll();
$smarty->assign('coolcuts',$coolCutsCharts);

$letters = array('0','A','B','C','D','E','F','G',
'H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U',
'V','W','X','Y','Z'
);
$smarty->assign('letters',$letters);

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

$smarty->display('catalogue_Index.tpl');

?>

Any ideas?

dmmh




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

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

UKSEOconsultant




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved