Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Content Editor Discussions /

Forum for content editors and CMS users.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dynamically add css class after calculating the string length using strlen

Go to End



Community Member, 1 Post

30 July 2015 at 6:52am

Edited: 31/07/2015 2:23am

I'm trying to add a css class dynamically in, by calculating number of strings a specific method/object is getting.

Is it possible to do?

What I'm trying is

 <div class=" my class <% if strlen($MyTitle) > 20 %>add-class<% end_if %> ">  $MyTitle </div>