Log in

View Full Version : Creating a TOC, how to?



shachi
12-22-2006, 03:13 PM
Hello everyone,

I was trying to create a TOC(Table Of Contents) script but I have no clue howto. Can anyone help me or give me a link to a website that teaches how to make one? Any help would be greatly appreciated.

Thanks.

djr33
12-23-2006, 01:40 AM
Ummm.... <a href="link">link</a><br>, repeat? :p

PHP could help, but only if your setup allows it to.

You could do a directory/file listing (there's a script around here that Twey ddi that could help), or you could use the information from a database. There might be other options as well, but those seem the most likley.

thetestingsite
12-23-2006, 01:45 AM
Take a look at the following links and see if this is sort of what you are looking for.

http://www.dhtmlgoodies.com/scripts/toc-maker/toc-maker.html
http://www.dhtmlgoodies.com/scripts/toc-maker/toc-maker-example2.html

Hope this helps.

shachi
12-23-2006, 07:51 AM
testingsite: It is something like that but, with PHP(I may use that if I change into ajaxifying the whole layout)

drj33: Can you tell me where that script is Twey made? My server(which is localhost) would allow me to do anything.;p I am not using a database by the way. I think there are TOCs made of PHP which get the content of headings and print them in a managable way(most wikis have them like dokuwiki).

drj33, thetestingsite: Thanks anyways.:)

djr33
12-23-2006, 09:09 AM
Hmm.... interesting.

You could do a directory listing script, then look for the <title> markup in the html. But, that might take a very long time. Not really sure, though.

here's my thread asking about a related topic... I'm sure some of these ideas could help you--
http://www.dynamicdrive.com/forums/showthread.php?t=14078

shachi
12-23-2006, 11:51 AM
Thanks, drj33!! I thought of doing a regexp search through the files(which are remotely included) but then again, I was not really good at regexps.

djr33
12-23-2006, 02:39 PM
regex is complex, and confuses me, but there's no real reason to ever NEED to use it... it just saves time. Instead of manually using 8 ifs, several while loops and such, you can just use a regex to do it by itself.
But.... not sure how it would help here.
If you did want to parse through the html, just split at the position at which <title> occurs, then again at </title>.
You could use explode too, and just use
list($null,$varyouwant) = explode('<script>',$html,2);
list($varyouwant,$null) = explode('</script>',$varyouwant,2);
where 2 is the limt of parts in case <title> accidentally appears twice, so it's not messy on the php end of things. But that might be a little innefficient... I dunno. I tried something like it recently but it was VERY slow, but it might be faster if you're not using remote files, if you're using local files without using an include statement and output buffer like I was.

shachi
12-25-2006, 08:19 AM
drj33: Well, let me try that.Thanks again!!

djr33
12-26-2006, 08:23 AM
Hmm... no clue why I put <script> and </script> there.... I meant title.
Oh well. :p