richardterris Posted May 28, 2008 Share Posted May 28, 2008 Hi all I have a site in which all the scripting is done on the index page, so that the individual page URLS would be www.mysite.com/index.php?page=pagename Within this page, the page title is defined, which leaves me stumped as to how to have seperate page titles for each page. I have looked around for a solution, and the closest thing i can see is an echo title command. The problem with my site is that each page is the surname of an artist, but for SEO reasons, passing the surname of an artist isn't really enough. Is there a way, without building a database, to create a page to contain page titles and descriptions, and call these depending on which page the user is on? If anyone needs to see any code, im happy to put it up, so just let me know. Hope you can help. Richard. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 Yes, please provide the code for index.php Quote Link to comment Share on other sites More sharing options...
richardterris Posted May 28, 2008 Author Share Posted May 28, 2008 <html> <head> <title>Art Galleries In Glasgow and London - Tracey McNee Fine Art</title> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="description" content="Tracey McNee Fine Art Ltd., specialists in contemporary art in the U.K. With galleries in Glasgow and London." /> <meta name="keywords" content="Scottish Artists, British Artists, Oil Paintings, Watercolour, Figurative, Landscape, Sculpture, Hand-made Glass, Ceramics, buy on-line, Glasgow Gallery, London Gallery" /> <meta name="robots" content="index, follow" /> <link rel="alternate" type="application/rss+xml" href="http://www.traceymcnee.com/rss.xml" title="Tracey McNee Fine Art"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <link href="resources/css/layout.css" rel="stylesheet" type="text/css" media="all" /> <!--[if IE]> <link rel="stylesheet" href='resources/css/ie_fixes.css' type="text/css" media="screen, projection" /> <![endif]--> </head> <body> <div id="container"> <!-- Container start --> <div id="container2"> <!-- Container2 start --> <div id="header"> <!-- Header start --> <?php include("header.php"); ?> </div> <!-- Header end --> <div class="colmask holygrail"> <div class="colmid"> <div class="colleft"> <div class="col1wrap"> <div class="col1"> <!-- Column 1 start, this is the main content --> <?php $url = ''; if (!empty($_GET['category'])) { $url .= $_GET['category'] . '/'; } if (!empty($_GET['page'])) { $url .= $_GET['page'] . '.php'; include $url; } else { include('page1.php'); } ?> </div> <!-- Column 1 end --> </div> <div class="col2"> <!-- Column 2 start, this is the left hand menu --> <?php include("mainmenu.php"); ?> </div> <!-- Column 2 end --> <div class="col3"> <!-- Column 3 start, this is the right hand menu --> <?php include("artistsmenu.php"); ?> </div> <!-- Column 3 end --> </div> </div> </div> <div id="footer"> <!-- Footer start, this is the bottom menu --> <?php include("footer.php"); ?> </div> <!-- Footer end --> </div> <!-- Container2 end --> </div> <!-- Container end --> <?php include_once("analyticstracking.php") ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
discomatt Posted May 28, 2008 Share Posted May 28, 2008 <?php switch ( $_GET['page'] ) { Case 'gallery': $title = 'Ary Gallery'; break; Case 'contact': $title = 'Contact Form'; break; Default: $title = 'Home'; break; } ?> <html> <head> <title><?php echo $title; ?></title> </head> ... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 You can also do something like this: <?php $url = ''; ob_start(); if (!empty($_GET['category'])) { $url .= $_GET['category'] . '/'; } if (!empty($_GET['page'])) { $url .= $_GET['page'] . '.php'; include $url; } else { include('page1.php'); } $contents = ob_get_clean(); $title = strlen($title) ? $title : 'Art Galleries In Glasgow and London - Tracey McNee Fine Art'; ?> <html> <head> <title><?php print $title; ?></title> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="description" content="Tracey McNee Fine Art Ltd., specialists in contemporary art in the U.K. With galleries in Glasgow and London." /> <meta name="keywords" content="Scottish Artists, British Artists, Oil Paintings, Watercolour, Figurative, Landscape, Sculpture, Hand-made Glass, Ceramics, buy on-line, Glasgow Gallery, London Gallery" /> <meta name="robots" content="index, follow" /> <link rel="alternate" type="application/rss+xml" href="http://www.traceymcnee.com/rss.xml" title="Tracey McNee Fine Art"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> <link href="resources/css/layout.css" rel="stylesheet" type="text/css" media="all" /> <!--[if IE]> <link rel="stylesheet" href='resources/css/ie_fixes.css' type="text/css" media="screen, projection" /> <![endif]--> </head> <body> <div id="container"> <!-- Container start --> <div id="container2"> <!-- Container2 start --> <div id="header"> <!-- Header start --> <?php include("header.php"); ?> </div> <!-- Header end --> <div class="colmask holygrail"> <div class="colmid"> <div class="colleft"> <div class="col1wrap"> <div class="col1"> <!-- Column 1 start, this is the main content --> <?php print $contents; ?> </div> <!-- Column 1 end --> </div> <div class="col2"> <!-- Column 2 start, this is the left hand menu --> <?php include("mainmenu.php"); ?> </div> <!-- Column 2 end --> <div class="col3"> <!-- Column 3 start, this is the right hand menu --> <?php include("artistsmenu.php"); ?> </div> <!-- Column 3 end --> </div> </div> </div> <div id="footer"> <!-- Footer start, this is the bottom menu --> <?php include("footer.php"); ?> </div> <!-- Footer end --> </div> <!-- Container2 end --> </div> <!-- Container end --> <?php include_once("analyticstracking.php") ?> </body> </html> then, on each of the 'included' pages, if you want a different title, just add a block of php code at the top setting the value of $title: <?php $title = 'This is what I want the title to be'; ?> This is the content of the included page Quote Link to comment Share on other sites More sharing options...
richardterris Posted May 28, 2008 Author Share Posted May 28, 2008 Brilliant Thanks a lot guys, that was really bugging me. Richard Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.