|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
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] http://developersouvik.orgfree.com |
|
||||
|
The simplexml_load_file documentation should include everything you need - there are numerous examples in the comments.
If you are not familiar with the PHP $_SESSION superglobal you will likely find that $_SERVER['REQUEST_URI'] is variable you have been looking for to map your XML data to individual URI's on your site (though, in the example below, my implementation uses the $_GET['page'] variable with a mod_rewrite directive instead). Your solution will ultimately look something like this: XML File: Code:
<?xml version="1.0" encoding="utf-8" ?> <pages> <page> <uri>/</uri> <title>Homepage</title> <content>This is the homepage.</content> </page> <page> <uri>/vocal-science.php</uri> <title>Vocal Science</title> <content>This is the page about vocal science.</content> </page> </pages> index.php Code: PHP Code:
mod_rewrite Directives: Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php?file=/$1 [L,QSA]
__________________
Dan LeFree | Product Manager (Linux VPS Hosting) | Owner/Operator (Web development, marketing) |
|
||||
|
While I agree it is probable that he is not copying another site, I am just suspicious by nature I suppose. However, if the content that will be used as the title and keywords is being stored locally, there might be more efficient ways of doing this - such as reading the information from a database, unless he is pulling a file from another website, where his options become more limited.
__________________
The best way to learn anything, is to question everything. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Home page Dynamic Vs Html static page | Steven1976a | Search Engine Optimization Forum | 4 | 05-27-2007 07:10 PM |
| Dynamic Title and Desc Tags - BAD??????? | schmeetz | Search Engine Optimization Forum | 3 | 11-09-2006 01:04 PM |
| Dynamic keyword list and title | bedford | Search Engine Optimization Forum | 1 | 02-21-2005 04:57 PM |
| Dynamic Page Title | Steven Glover | Search Engine Optimization Forum | 3 | 08-02-2004 10:57 PM |
| Formatting Meta tags: title VS DC.title VS http-equiv=title | Sergio Simarro | Search Engine Optimization Forum | 8 | 05-27-2004 12:48 PM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |