We use cookies to ensure that we give you the best experience on our website. We also use cookies to ensure we show you advertising that is relevant to you. If you continue without changing your browser settings, we will assume that you are happy to receive all cookies on this website.

Flexible HTML code block in your blogs WYSIWYG editor

Sometimes you need to add HTML-code to a blog article, i.e. an iFrame or some code to include a third party (YouTube) movie. Using a WYSIWYG editor this isn't possible, you need to put the code in a global content block or generic template and copy the tag in the text-editor. Having a small website this works fine, but for large websites it is a different story. The down side is you get lots of GCB's associated with different articles, the admin doesn't get clearer of it...

I like to see all text and code for an article at one place. The solution wasn't that hard, I created a custom content block for code in each article. The editor can call that block with one smarty tag *in* the WYSIWYG editor.

How to use

Open the CGBlog module and add a new Field Definition.

Name: codeblock

Type: Text Area

WYSIWYG: off

Public: checked

Add one line to the top of your summary template, directly after the {foreach ...} line:

When you create a new article you will see a new content block at the bottom of the page. Copy your custom HTML code in this block! At the place where you want to have the code included in the article add in the WYSIWYG editor the tag:

Comments

Click here to leave a comment

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!In case of abuse your IP address will be blocked!

Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!! Consider buying Rolf a cup of coffee in return! [ Click here ]

1 Comment

Oct 4, 2014

blackhawk

Your guide inspired me to look into doing this OOTB with the News module. You can complete the same objective with the news module by capturing the field and assigning the capture as a variable, which could then sit anywhere in the summary or detail article blocks.