Showing unique page titles with php

Discussion in 'PHP' started by Vagabondette, Aug 27, 2008.

  1. #1
    I'm sorry if this is covered somewhere but search wasn't working for me.

    I'm wondering how to generate page specific titles and meta tags using php. The way my site is currently set up there's are header and footer pages which show up on each page and then the content page which is separate. It makes editing easier, but it means that even though I have unique content on each page they all have the same page title and meta tags.

    Is there a way to code it so that the page title and meta tags are pulled from the content section rather than the header or do I just need to have everything on one page so I can manually change the meta info for each page?

    Thanks for any help.
     
    Vagabondette, Aug 27, 2008 IP
  2. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    couple of different ways you could approach this...

    1.) you could put the page titles and data into an array and run a page check
    and if it matched the page.php then produce the proper results.

    2.) You could have text files for the pages and then do an array of page.php
    and then extract the data from those text files if it matches

    3.) you could hard code it into your header.php file and do a bunch of if statements
    and it would check against a page to see what data it's supposed to pull

    ex:

    if($page === "test.php"){
    $title = "My Test Page";
    $meta_tags = "Testing, test, testie, mr testies";
    $med_desc = "This is my testing page";
    }

    Then just call it in your header page
     
    IGiveMoney, Aug 27, 2008 IP
  3. Vagabondette

    Vagabondette Member

    Messages:
    438
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    35
    #3
    Thanks for the response. #3 probably sounds easiest since my coding skills ended with me being able to create a table with HTML. :)

    You said to call it in the header... What does that mean?

    Thanks again!
     
    Vagabondette, Aug 28, 2008 IP
  4. brassdragon

    brassdragon Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have a code that i use on my site that changes the metas and title - pm me if interested
     
    brassdragon, Aug 28, 2008 IP