questions about using include() in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • runway27
    Banned
    New Member
    • Sep 2007
    • 54

    questions about using include() in php

    i am doing seo for a website and this website uses a lot of php for which i need suggestions. this is how the website is set up.

    in the index.php file there is a flash banner at the top of the page and the center part is another file which is called using include("links. php") and the bottom part using include("footer .php")

    the footer has links such as = webdevelopment software development ... each of this has a query string= http://website.com/index.php?page= webdevelopment and http://website.com/index.php?page= software ... etc

    this way every link in the website is calling index.php and a query string is being passed and the index.php looks for the name ex=webdevelopme nt and loads that particular page in the center section of the website. the main purpose of doing this was to load the flash file only 1 time and the rest of the time when the links from the footer are clicked only the center part changes and the flash file does not have to reload.

    due to this the entire website is having only 1 page index.php therefore using 1 <title> tag 1 meta description and 1 meta keywords tag as the values of <title> and <meta> tags are being displayed from index.php

    however from a seo and sem perspective ideally there should be different file name which means i can optimize the <title> and <meta> tags for individual files.

    please advice a best solution to get around this as i would like to have different title and meta tag for individual pages like webdevelopment. php software.php etc which i am presently not able to due to include("")

    any help will be greatly appreciated.

    thanks.
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    I have two headers and one footer for include. So I have header_1.php which has session declaring and opening the <head> tag. Then header_2.php has the rest of my header (without any <title> tag). This is what my pages look like:
    [PHP]<?php
    include( "header_1.p hp" );
    echo( "<title>Thi s specific page title</title>" );
    include( "header_2.p hp" );

    include( "page_content.p hp" );

    include( "footer.php " );
    ?>[/PHP]


    Yeah, I love include()!

    Comment

    • nitinpatel1117
      New Member
      • Jun 2007
      • 111

      #3
      the way that you have describe the structure of the website. i.e. the query strings.. The flash file will always reload itself.

      Comment

      • nitinpatel1117
        New Member
        • Jun 2007
        • 111

        #4
        I Think what you are after is something like this.

        Basically you need to output a <title></title> based on the query string.

        therefore in your footer you probably have a HTML line like

        [HTML]<title>........ ......</title>[/HTML]

        you need to replace this with the following php code
        [PHP]<?php

        $current_page=" ";
        if (isset($_GET['page']) && $_GET['page']!='')
        $current_page = $_GET['page'];

        switch($current _page)
        {
        case "webdevelopment ": echo "<title> Web Development page </title>"; break;
        case "software": echo "<title> Software Page </title>"; break;
        case default: echo "<title> This is a fall-back title </title>"; break;
        }
        ?>[/PHP]

        I have just given two examples above i.e. where page equals webdevelopment or software. But you can add more in there by copying and pasting that line in a few more times and then changing the text that is after the 'case'.

        You can built on my code above by adding META tag related content in there as well.

        Comment

        Working...