If this is your first visit, check our documentation. To post, register or login.
Forums / Zen Cart Code Suggestions / Add simple count to meta title and meta descriptions

Add simple count to meta title and meta descriptions

Started by llynix on 2 Jun 2016, 8:29 PM · Views: 72

Results 1 to 3 of 3
2 Jun 2016, 8:29 PM
#1
llynix avatar

llynix

Zen Follower

Join Date:
Jul 2009
Location:
Texas
Posts:
210
Plugin Contributions:
0

Add simple count to meta title and meta descriptions

Google and other search engines like your titles and descriptions to be a certain length. I wrote this piece of code today to easily display a count of how many characters I had in my titles and descriptions.

File to modify is: /admin/includes/footer.php

</footer>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
function char_count(max, selector) {
	var selector_name = selector.replace(/[^\w]/g,'');
	var char1 = max - $(selector).val().length;
	$( '<span class="count_' + selector_name + '">(' + char1 + '/' + max + ')</span>' ).insertAfter(selector);
	$(selector).keyup(function () {
  	  var char2 = max - $(selector).val().length;
	  $('.count_' + selector_name).text('(' + char2 + '/' + max + ')');
	});
}
char_count(60,'input[name^=metatags_title]:text');
char_count(160,'textarea[name^=metatags_description]');
</script>

Hope it helps someone.

DentalPlanet Designed/Administrated by Falls Geek

3 Jun 2016, 9:06 AM
#2
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Add simple count to meta title and meta descriptions

That's cool. Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

4 Jun 2016, 12:48 AM
#3
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Add simple count to meta title and meta descriptions

Yes, that's very handy, thanks for sharing!


Zen Cart and it's community are the best!!