EllisLab text mark
Advanced Search
     
If over ‘xx’ characters plugin?
Posted: 19 July 2012 09:19 AM   [ Ignore ]
Joined: 2012-05-04
12 posts

Does anyone know if it is possible or if there is a plugin available that will count the number of characters generated by several different fields created by expressionengine and if over a certain value, say 80 characters be able to change to a different css style to accomodate.
I guess I’m looking for something I can put in a conditional so that if over 80 character change to <div>2row</div> or similar?

 
Posted: 22 July 2012 05:09 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-10-10
55 posts

Hi iancoote,

I have whipped up a plugin for you that should do the trick.

Plugin Usage:

Enter in as many fields/strings you would like to count the
character of 
and seperate each with a pipe.

This plugin is to be used inside a channel tag pair.

{exp:channel:entries channel="xxx"}

    {exp
:character_counter data="var1|var2|var3"}

{
/exp:channel:entries}

You can also 
use any expression engine fields you
have access too
.

{exp:channel:entries channel="xxx"}

    {exp
:character_counter data="{url_title}|{title}"}

{
/exp:channel:entries}

There is an optional parameter to tell the plugin not to count spaces
this is true by default.

Optional Parameter Usage:

{exp:character_counter data="{member_id}|{username}" count_spaces="false"}

Usage
:

{exp:channel:entries dynamic="no" channel="blog"}
    {if {exp
:character_counter data="{member_id}|{username}"4}
        More than 4 characters
    {
/if}
{
/exp:channel:entries}

Have fun

Expression Engine just like any CMS andcant cater to every need but luckily expression engine is very flexible and easily extended, starting with plugin development, great info

Here in the plugin development docs

Hope this helps.

 
Posted: 23 July 2012 07:25 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-05-04
12 posts

Hi DigitalDoctors,

That’s really great thank you very much for your kind help and assistance.

Best wishes,
Ian.