HTML in News Title?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
tonicdesign
New Member
New Member
Posts: 7
Joined: Thu Apr 28, 2016 10:56 pm

HTML in News Title?

Post by tonicdesign »

I'm working with several energy companies and we routinely need to use the term CO2 in titles, and the '2' should be subscript. Adding in the appropriate tag just outputs everything (e.g. CO<sub>2</sub>). Any way to allow for this? I have custom fields set up on page templates so we can do it in headers, etc., but not in the News module, which makes for inconsistent content.

CMSMS 2.2.7
News 2.51.3
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3484
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: HTML in News Title?

Post by velden »

Simple workaround:

Create a new user defined tag named 'CO2'

Code:

Code: Select all

echo 'CO<sub>2</sub>';
In your news articles then use {CO2} where you want this text to appear.

In your news templates make sure to use {eval ...} on the news content. E.g.

Code: Select all

{eval var=$entry->content}
This {CO2} tag can be used in content too.
tonicdesign
New Member
New Member
Posts: 7
Joined: Thu Apr 28, 2016 10:56 pm

Re: HTML in News Title?

Post by tonicdesign »

Perfect - thank you! For anyone following this thread just make sure to put the 'eval var=$entry->…' wherever you want to use this. For example:

In the {content} area of News, use {eval var=$entry->content}.

In the Title, use something like {eval var=$entry->title}, or {eval var=$entry->title|cms_escape}.

Works like a charm, just remember to add the 'eval var=$entry->…' to ALL of the templates used - summary, special use summary like summary-home, detail, etc. or you'll see curly brackets showing up.

Thanks again velden.
Locked

Return to “CMSMS Core”