Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

MOD: Add word counter to meta descriptions & keywords Rate Topic   - - - - -

 
  • S-Combs
  • Senior Member
  • Members
  • Join Date: 09-Nov 06
  • 692 posts

Posted 23 March 2011 - 01:16 AM #1

This has been requested a couple times so I decided to throw one together.

This modification will add a simple word counter under the Meta description and (optional) Meta keyword input fields when adding or updating products.

Posted Image

Tested only on version 2.1.4 with IE8 and FF3.6 and 'not completely' so be prepared to revert if needed.

Requires:
1 template edit
1 file upload

Known issues:
When loading a product with existing words in these fields the counter will show 0 until a key is pressed in the field...
reserved
reserved

Possible issues:
May conflict with other javascript especially if you have other product option related addons.

Instructions:

Upload jquery.meta_counter.js to the /js directory

(Option 1) Skip to Option 2 below if you want description AND keyword word counters


========= Meta Description Counter Only ===========

Template Edit

Open skins/yourskin/admin/views/products/update.tpl

Add this to the top of file
{script src="js/jquery.meta_counter.js"}
{literal}
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        $('#product_meta_descr').descrCount();
    });
    //]]>
</script>
{/literal}
find this line in same file
<textarea name="product_data[meta_description]" id="product_meta_descr" cols="55" rows="2" class="input-textarea-long">{$product_data.meta_description}</textarea>
add this directly below it
<p><span style="color:#FF0000">Word Count : <span id="meta_description_counter">0</span></span></p>
Save file

!!! Clear Cache !!!

========
Finished
========


(Option 2)

========= Meta Description And Keyword Counters ===========

Template Edit

Open skins/yourskin/admin/views/products/update.tpl

Add this to the top of file
{script src="js/jquery.meta_counter.js"}
{literal}
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        $('#product_meta_descr').descrCount();
    });
    //]]>
</script>

<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        $('#product_meta_keywords').keywdCount();
    });
    //]]>
</script>
{/literal}
find this line in same file
<textarea name="product_data[meta_description]" id="product_meta_descr" cols="55" rows="2" class="input-textarea-long">{$product_data.meta_description}</textarea>
add this directly below it
<p><span style="color:#FF0000">Word Count : <span id="meta_description_counter">0</span></span></p>

find this line
<textarea name="product_data[meta_keywords]" id="product_meta_keywords" cols="55" rows="2" class="input-textarea-long">{$product_data.meta_keywords}</textarea>
add this directly below it
<p><span style="color:#FF0000">Word Count : <span id="meta_keyword_counter">0</span></span></p>
Save file

!!! Clear Cache !!!


========
Finished
========

Attached Files


Secure Cart Hosting
[CS-Cart Optimized Solutions and Server Management]

 
  • miracles
  • Senior Member
  • Members
  • Join Date: 19-Sep 07
  • 1533 posts

Posted 23 March 2011 - 05:14 AM #2

Thanks mate. But i am getting problem. when i enter words it is still showing counting 0

Attached Files

  • Attached File  word.JPG   12.35KB   21 downloads

CS-CART 3.0.6 GRENADE

Please vote for CDN Add-on

For SEO Article Submission, Forum Profile Links, Web 2.0 links, contact me through PM.

 
  • miracles
  • Senior Member
  • Members
  • Join Date: 19-Sep 07
  • 1533 posts

Posted 23 March 2011 - 05:18 AM #3

Thanks mate to accept my request :D
CS-CART 3.0.6 GRENADE

Please vote for CDN Add-on

For SEO Article Submission, Forum Profile Links, Web 2.0 links, contact me through PM.

 

Posted 29 October 2011 - 01:53 AM #4

This was a great idea, and I followed the instructions (that were very clear) to the letter, however the result is still

Word Count : 0

regardless of how many words I type in the SEO/Meta Meta description box in the product edit/add page.

I am using the 2.2.3 version and this was tested with 2.1.4 so I wander if this could be the reason.


Does anyone have any idea what could be wrong? Any help is appreciated

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1442 posts

Posted 10 December 2011 - 08:38 AM #5

Well as I tried the mod, it seems in 2.1.4 that it only works when you type in the fields. If you save and return its always 0. I supose it reads only the keyboard and not the database table cells.

I dont find it annoying cause I need that only once, when I enter the fields. It could be fixxed if it could store the count in a cell on the db at the products table on a ceperate row.

Anyway thanks, it is a major improvment to the original cs-cart.
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller