Adding an ID attribute to all headers in content

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
SimonSchaufi

Adding an ID attribute to all headers in content

Post 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?
Last edited by SimonSchaufi on Mon Mar 02, 2009 11:13 am, edited 1 time in total.
nhaack

Re: Adding an ID attribute to all headers in content

Post 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
SimonSchaufi

Re: Adding an ID attribute to all headers in content

Post by SimonSchaufi »

need to think more about this idea...

any other ideas are welcome of course.
Post Reply

Return to “Developers Discussion”