Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Retrieve & Display Another Page's Title

Retrieve and display another page's title



10:25 pm on Nov 11, 2009 (gmt 0)

5+ Year Member

I want to make a directory of all the photo galleries in my website (individual pages) and display their ID number and page title on the directory page. I plan to use a loop to create the sequential ID numbers, retrieve the page titles of the URL provided with the ID added at the end (ie: album_id=203), then display both. Can someone please help me with this?


3:48 am on Nov 17, 2009 (gmt 0)

5+ Year Member

Does the gallery content change so often that you must do it dynamically rather than keeping a static list of the titles and their IDs?

If you do it dynamically, you'll need to guard against malicious remote file inclusion, in the code that processes incoming requests for the gallery pages.

The page titles are between <title> and </title> tags in the source code. You'll need to open the files and use regular expressions to extract what's between those tags in each page.

Assuming the IDs match the filenames, you can get a list of them by getting a directory listing. If you generate the IDs in a loop, you'll just need to check to see if each possible numeric ID matches an existing file; if it does, open it and get the <title> contents.


1:07 am on Nov 21, 2009 (gmt 0)

5+ Year Member

I don't have to keep it dynamic, but there's already so much content created that it'll take too much time to manually create a directory, so I was hoping this script could do the work for me.

However, I ran the idea by my boss and he said that the last time a robot (which this is essentially) tried to index all our galleries it screwed up the system and skewed the site statistics, so I've pretty much been told to abandon this plan. Thanks for the help though!


6:02 am on Nov 21, 2009 (gmt 0)

5+ Year Member

Ok. I interpreted your inquiry as being about a dynamic page that builds the index page each time a visitor requests it, which seemed like a lot of potentially unnecessary server overhead.

If a static index page is acceptable, then you can probably create some automated methods similar to what I described, that will help create ID/title pairs which you can then put on a static index page for use on the live site. I.e. you would run that program only once to help you build the static page, then upload the page you created to the server.


Featured Threads

Hot Threads This Week

Hot Threads This Month