Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
18 posts Page 2 of 2
Hey tim, just wanted to say thanks for a great Couch addition!
I work closely with an SEO guy who asked me if it would be possible to have a character counter for the title and description fields. One quick search of the forum, and my problem was solved!
Thanks again.
Am I correct this addon doesn't work if row is deleted?
It sounds like you're referring to an issue with repeatables. If you delete a row that is connected to a character counter, it breaks the 'add a row' listener of the add-on. New rows won't have a counter attached. If you save or refresh the page, then it will work normally again. I left a comment in the code about it.

I hadn't thought about this in a long time. Maybe it's time to take another look and see if I can sort that problem out.
I have refactored the character counter add-on to play nice with the dynamic elements of repeatable regions. Hope this helps with the issue you brought up, @trendoman.

I'll drop the new zip here for now and update the primary upload once it has a chance to age and mellow a little.

Update: Deleted file. Still working on it.
I've spent some time with this add-on and have it purring like a kitten! I've fixed the code so that it now plays nice with repeatable regions. I also improved and cleaned up the code generally, and even added some new features: an 'enforce_max' parameter to strictly limit the text that can be entered, and a "warning light" to let the user know they are approaching the character limit.

The new, updated add-on can be downloaded from the zip at the beginning of this thread.
viewtopic.php?f=8&t=10339&p=25233#p25233

Hope you like it!
Updated this add-on with language localization. You can now localize or customize the language for the built-in labels and warning message by adding parameters to the Couch tag.
Code: Select all
<cms:character_counter lang_warning="Maximum Reached" lang_max="Max: " lang_min="Min: ">
    { editable:'strict_counter', max:140, min:20, show:'min max', enforce_max:true }
</cms:character_counter>
Hello, this is exactly what I needed, clear and straightforward!
When applying to editables within page it works fine, but I've noticed that the counter does not appear if I have a SEO page description editable in the template globals. Sample code:
Code: Select all
        ...
        <cms:editable name='page_meta' label='Meta info' type='group' order='100' />
        <cms:editable name='page_title' type='text' label='Page title' group='page_meta' maxlength="255" />
        <cms:editable name='page_desc' type='textarea' height='80' label='Page description' group='page_meta' />
        <cms:editable name='page_keywords' type='textarea' height='80' label='Page keywords' group='page_meta' />
</cms:template>

<cms:globals>
        <cms:editable name='page_meta' label='Meta meta' type='group' order='100' />
        <cms:editable name='gt_page_title' type='text' label='Page title' group='page_meta' maxlength="255" />
        <cms:editable name='gt_page_desc' type='textarea' height='80' label='Page description' group='page_meta' />
        <cms:editable name='gt_page_keywords' type='textarea' height='80' label='Page keywords' group='page_meta' />
</cms:globals>

<cms:config_form_view>
    <cms:script>
        <cms:character_counter>
            { editable:'page_desc'},
            { editable:'gt_page_desc'}
        </cms:character_counter>
    </cms:script>
</cms:config_form_view>

What do you think?
Hello @gali.

I'm sorry, but I'm no longer in a position to provide very good support for my Couch add-ons. I haven't used or kept current with Couch in a long time. I don't even have a test site set up to mess around with.

Having said that, maybe I can suggest some trouble-shooting steps.

Have you tried looking at the generated source code using your browser's dev tools? It usually is obvious how the code is malformed, and you can work backwards to correcting the problem causing it.

The code fragments you provided don't exactly make sense to me. The config_form_view tag is meant to be inside of the template tag. Are you certain that your tags are configured properly?

This character_counter tag simply injects js into the page. If it's not working in a particular instance, it's most likely not being added to the page properly. It might be out of place or missing. Again, viewing the source can help you to figure out what went wrong.

Sorry I can't give a more concrete answer or do any actual trouble-shooting for you. But I hope that helps you to move forward.
18 posts Page 2 of 2