![]() |
Extracting page titles and placing into dropdown box.
Hi, I've been trying to figure this out for the past few days but can't do it. I am usless at explaining things so I'll do it in point form..
p1 ). I have a text area where an article is written e.g. Code:
<h5>Title for Page 1</h5>p2) On the public front end a script splits the record up into 3 pages and outputs links such as "Prev - 1, 2 ,3 - Next">. I have reached this stage and it all works perfectly. p3) The issue(s*) I have is that to make navigating easier I would like the page titles to appear in a drop down box and when submitted the user would be taken to the appropriate page; See here. How does one extract the page titles and stick them in a drop down box? *In addition to this I am using [NEWPAGE] above each page title (<h5> tags) in the article creation text box to indicate a new page and its this that explode() looks for when creating pages, I would rather it actually search for the page titles them selves which are housed between <h5> tags. |
If the title is stored in the database, you could quite simply run a query and return all the titles of all the pages.
|
Thanks for your suggestion, it gave me an idea. It's weird how one can spend days trying to figure something out and they think they have exhausted all options that their skill will allow for, but then you read a suggestion on the net, which gives you an idea which is simplistic in nature to implement and then you think of your self as a muppet for not being able to think the solution up previously....
PHP Code:
|
Where is your page content coming from with the above code?
|
I've trimmed all the layout elements out as well as any non essential php...
PHP Code:
|
Here's something which might be useful, please don't just use the code as-is but take it's ideas and concepts (and main function hehe) to fit into your project. The code provided will (should) work in a standalone manner just to show you everything. It uses
preg_split, I'm sure there are other alternatives of which this is just one example.PHP Code:
|
That was very generous of you to do that salathe. I got it working, after some tinkering. I'm now working on adding the prev - next links back in. I will post the finalized script in the coming days. Thanks again for that script it works a charm.
Oh when I say it works a charm, there is one slight problem. It appears that if there is a string before any <h5> tag then the script won't split the content into a new page for some reason, so all <h5> tags must be on a new line. For example the below string produces just two pages when really it should be three... Code:
$azArticle = "<h5>page 1</h5>page one contentCode:
$azArticle = "<h5>page 1</h5>page one content |
| All times are GMT. The time now is 12:25 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0