Page 1 of 1

HTML in News Title?

Posted: Thu Dec 06, 2018 6:23 pm
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

Re: HTML in News Title?

Posted: Thu Dec 06, 2018 7:45 pm
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.

Re: HTML in News Title?

Posted: Thu Dec 06, 2018 9:52 pm
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.