Page 1 of 1
title dynamic - half way there
Posted: Sun Nov 27, 2011 12:21 pm
by gaogier
I have created this.
http://pastebin.com/5fFdT6n6
I now need to get the title of the guide type showing.
Example,
http://runehints.com/quests/149/All_Fired_Up - the title should be .:RuneHints:. Quests - All Fired Up
http://runehints.com/quests/114/Another_Slice_of_H.A.M. would be .:RuneHints:. Quests - Another Slice of H.A.M.
Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 12:46 pm
by Celauran
Have you tried exploding $_SERVER['REQUEST_URI'] and then removing the underscores with str_replace?
Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 12:47 pm
by gaogier
Sorry, I am a novice at php, I am proud I managed the first step.
I am googling what you said

Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 12:51 pm
by Celauran
$_SERVER['REQUEST_URI'] will contain a string like /quests/149/Whatever
Use
explode() with / as a delimiter to break apart the string into an array. The last element in the array will be your quest name. Finally, you can use
str_replace() to replace the underscores with spaces, and there's your page title.
Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 1:23 pm
by gaogier
Do you have an example, I am trying to find one online but not sure
Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 1:36 pm
by Celauran
Try something like this:
Code: Select all
$uri = $_SERVER['REQUEST_URI'];
$parts = explode("/", $uri);
$title = $parts[count($parts) - 1];
$title = str_replace("_", " ", $title);
Re: title dynamic - half way there
Posted: Sun Nov 27, 2011 4:11 pm
by gaogier
Thanks for your help. Problem resolved

Re: title dynamic - half way there
Posted: Mon Nov 28, 2011 9:41 am
by McInfo
Some other functions to be aware of: