Skip to content

News Posting

Trang Pham edited this page Aug 8, 2017 · 3 revisions

Dynamic Page Titles

_Tuesday November 8th, 2016 - by Trang Pham, The Web Designe_r

I missed last Thursday November 3rd to a nasty flu. After all catching up on the form handler and plug it into a web page template, we learned to use PHP function to update have the page’s title updated as we are moving from one page to another.

It a form of breadcrumbs of the site letting user know where they currently landing on. Currently with the same header.php plugged in for all the pages, the page’s title however is not “yet” being updated uniquely for each page. So today Bill taught us how to use php to update the title as we navigating from one page to the other. We did not do this directly on the header.php, instead we created config.php. Of course this was linked on the very top of template.php the same way we linked the header.php and footer.php. On config.php we added the usual:

to define the page’s name:

define(‘THIS_PAGE’,basename($_SERVER[‘PHP_SELF’]));

to clear all the date errors of all sorts:

date_default_timezone_set(‘America/Los_Angeles’);

First we updated the title using Switch Case $title:

switch(THIS_PAGE)

{

    case ‘template.php’:

    $title=’Template Page’;

break;

case ‘contact.php’:

   $title=’Contact Page’;

break;    

default :    

   $title = THIS_PAGE;

}

Once this is done it also updates the page Banner.

Lastly, we updated the page navigation bar so it listed all the items and also still highlight the current page we are on.


©2016-2017 TidbitWebDesign - All rights reserved

Clone this wiki locally