Page 1 of 1

Adding an ID attribute to all headers in content

Posted: Mon Mar 02, 2009 11:04 am
by SimonSchaufi
i have something in my mind but i dont know how to solve it.

i would like to parse the whole content and add an id attribute to all headers (no matter what type of (h1, h2, ...)) before content is displayed. i dont want to do this manually in wysiwyg.
WHY?
because i would like to show a table of contents (like wikipedia) at the beginning of a page and i want to send the parsed content to this udt so that the udt can create links to all headers.

the table of contents udt is the following:

http://wiki.cmsmadesimple.org/index.php ... f_contents

can somebody help me with that?

Re: Adding an ID attribute to all headers in content

Posted: Mon Mar 02, 2009 9:09 pm
by nhaack
Could you use some kind of regex with smarty on the output?

Code: Select all


{$foo|regex_replace:"pattern":" id=... "}

I'm not that good with regex... but this could be a start - I think.

http://www.smarty.net/manual/en/languag ... eplace.php

Best
Nils

Re: Adding an ID attribute to all headers in content

Posted: Fri Mar 20, 2009 11:24 pm
by SimonSchaufi
need to think more about this idea...

any other ideas are welcome of course.