Results 1 to 3 of 3

Thread: Dynamic <title> according to page URL

  1. #1

    Dynamic <title> according to page URL

    Hi All
    I am new to php and trying to learn it.

    I am developing a website using <?php include(''); ?> function. Entire website is divided into 5 templates such as "meta.php","header.php","navigation.php","righ t-menu.php", "footer.php". Till now <title>, <meta keywords>, <meta description> are static and place manually. I want these information to be dynamic from a .xml file stored inside server.

    I am already able to fetch <meta keywords> and <meta descriptions> using php "simplexml_load_file". I want <title> to appear according to page URL/page name.I have few sets of <title> for each individual page inside .xml file. As an instance,for http://www.examplesite.com/vocal-science.php I have "Vocal Science" string.

    Is it possible to fetch individual keywords from .xml file according to page URL? This is the solution I am looking for desperately. Any example or any tutorial is appreciable.

    Thanks in advance
    developersouvik
    Web2.0 Designer
    developersouvik
    Technology & Creativity Spun Together
    designguru1980@hotmail.com
    http://developersouvik.orgfree.com

  2. #2
    First you need to be able to pull the name of the currently loaded file and set it to a variable:

    PHP Code:
    <?php
    $page 
    $_SERVER['PHP_SELF']
    ?>
    now $page will be set to the name of the file.

    In your XML you will need to have in each section:
    1. The name of the file
    2. The title you want
    3. The keywords you want

    Then when the page loads you load the title and the keywords from the section in the xml where it's name matches $page

    Those variables are then used in the code.


    Does this make sense?
    Last edited by birdwing; July 26th, 2009 at 02:17 PM.

    Twitter / The Human Conditions

    biznuge: "that doesn't grammatical sense..."

  3. #3

    Thanks birdwing

    Hi birdwing

    Thanks for your post. Let me try it, I'll let you know whatever the result comes out.

    Thanks again..

    Regards-
    developersouvik
    Web2.0 Designer



    Quote Originally Posted by birdwing View Post
    First you need to be able to pull the name of the currently loaded file and set it to a variable:

    PHP Code:
    <?php
    $page 
    $_SERVER['PHP_SELF']
    ?>
    now $page will be set to the name of the file.

    In your XML you will need to have in each section:
    1. The name of the file
    2. The title you want
    3. The keywords you want

    Then when the page loads you load the title and the keywords from the section in the xml where it's name matches $page

    Those variables are then used in the code.


    Does this make sense?
    developersouvik
    Technology & Creativity Spun Together
    designguru1980@hotmail.com
    http://developersouvik.orgfree.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012