RSS 2.0
RSS 0.91
ATOM 0.3
February 19, 2008

Inserting content elements in the RTE

Category: Søren Andersen, TYPO3

By: Søren Andersen

Have you ever been working with an extension, where you would like to include some content element on the page where the plugin is displayed? Yesterday I wanted to know how I could do that, so I decided to find out.

I have previously on this blog described a method I use to have total control of every page on my TYPO3 website. This method might not be the best solution, but it enables me to do what I want: control the content on every page of my website with the standard content elements of TYPO3. Let me give you an example: When you install tt_news and set it up, you will most like have 1 page in the pagetree for the LIST type, and 1 page in the pagetree for the SINGLE type. This means that all your news are shown on the page with the SINGLE type plugin. If you decide to add some google ads to that page, you will have to insert them on all the news, and you cannot easily make a different structure for your ads, or decide that some news don't have ads. This is because you only have the one RTE to write your text in.

Yesterday I decided that I would have a section with frequently asked questions about hypnosis and hypnotherapy. And since I'm a big fan of lib/div, I wanted to use the efaq extension (great extension by the way! very flexible). The way i configured the extension means that it is structured like the way I described tt_news. And this is rather limiting if I want to insert some content elements on the page where the answer is. I thought about how to solve it, and I figured that a custom tag like <content> would be nice. I figured that I couldn't be the only one who has ever wanted this feature, so I posted a request on the danish mailinglist to ask if such a solution existed out there. Christian Jul Jensen pointed me in the direction of typoscript, and I actually got it to work! Here's the typoscript I used:

lib.parseFunc_RTE.tags {
content = CONTENT
content {
  table = tt_content
  #List of UID's of pages where the content elements are
  select.pidInList = 98
  select.andWhere.current = 1
  select.andWhere.wrap = uid=|

With this code I can simply write <content>23</content> to get the content element with ID=23. And now, you can do so too! As I said on the mailinglist, this is really the reason why TYPO3 is my favorite CMS. It also demonstrates the power of typoscript!


comment #1
Gravatar: Ralf Merz Ralf Merz February 19, 2008 14:46
Hey Soren,
looks great! i didn´t know that! Thank you very much for this Information!

comment #2
Gravatar: Charles Coleman Charles Coleman February 20, 2008 19:39
Thanks so much for sharing this. I have wanted to do this before as I'm sure many others have as well.

comment #3
Gravatar: Steffen Müller Steffen Müller February 21, 2008 00:52
Awesome! I've been working with TYPO3 for more than 6 years now, but this is news for me! And it works like a charm.


comment #4
Gravatar: Torsten Schrade Torsten Schrade March 10, 2008 12:12
Great stuff - Thank you very much indeed! Tiny addendum for those who (like me) do encounter problems with the RTE parser wrapping p tags around content from CEs inserted with like this (e.g. the normal table CEs): just set lib.parseFunc_RTE.tags.content.breakoutTypoTagContent = 1 and the HTMLparser won't touch it.

Sorry, comments are closed for this post.