Setting a unique title/meta with Templates

Discussion in 'HTML & Website Design' started by FPForum, Oct 15, 2007.

  1. #1
    Hey everyone. The website I am currently working on uses template and php files. I would like to have it so each page has its own unique title and meta tages.
    Currently, each php file calls a standart background.tpl file that has the <head> and some other information in it, the php file also calls the unique page tpl file which has the page information on it. The problem with this is that each page uses the same title and meta tags. Anyone know how I can fix this so each tpl file has a unique title and meta tags??

    any help is appriciated and certainly worth some green rep points!!
     
    FPForum, Oct 15, 2007 IP
  2. WTM

    WTM Peon

    Messages:
    500
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to define a title for each of your php pages and than call those titles as a php code from your background.tpl file
     
    WTM, Oct 15, 2007 IP
  3. FPForum

    FPForum Notable Member

    Messages:
    4,172
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    225
    Digital Goods:
    2
    #3
    thanks WTM, from my background.tpl or from each individual pages tpl? (for example, bluewidget.tpl, greenwidget.tpl..etc)
     
    FPForum, Oct 16, 2007 IP
  4. diropeth

    diropeth Active Member

    Messages:
    452
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    70
    #4
    i have same problem :confused:
     
    diropeth, Oct 22, 2007 IP
  5. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Or use a database.
     
    login, Oct 22, 2007 IP
  6. diropeth

    diropeth Active Member

    Messages:
    452
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    70
    #6
    have you an example? :confused:
     
    diropeth, Oct 24, 2007 IP
  7. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Sorry, I dont know more, I use that system myself, but dont know how the system works really.
     
    login, Oct 24, 2007 IP
  8. Jeff Blake

    Jeff Blake Peon

    Messages:
    32
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Create variables for title, and meta tags.
    In each page it would look like this:

    
    $title = 'This is the title of this specific page';
    $meta_tag1 = 'blah blah';
    include('background.tpl');
    
    PHP:
    Remember you must define the variable before you include the file.

    EDIT: You also need to edit background.tpl:
    Remove the title and tell it to echo the title variable (ex. if title is <title>Welcome</title> ... change to <title><?php echo $title; ?></title>)
    Do the same for meta tags
     
    Jeff Blake, Oct 24, 2007 IP
    FPForum likes this.
  9. FPForum

    FPForum Notable Member

    Messages:
    4,172
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    225
    Digital Goods:
    2
    #9
    Thanks so much Jeff. Rep left for your excellent example and explanation! :)
     
    FPForum, Oct 25, 2007 IP