I have done some "tweaks" for the popular posts gadget, and here's another cosmetic one. The gadget cuts the post snippet at a fixed character index, so it can cut words in half, which is quite stupid. It would be much better to cut the post text at a word break. This little hack I made does that, using jQuery.
Sometimes little things matter. :)
You can install this hack by adding an extra HTML/Javascript gadget in your sidebar, or paste the code to an existing gadget (the gadget must be after the popular posts gadget!). Or you can put this code in your template html, just before </body>. If you have my Shuffle or Shuffle and limit hack for popular posts installed, put this code in the same place, after that hack's code.
You must have jQuery loaded in your page for the script to work. Script, installed also on this blog, won't cut the text smaller than 42 chars. Hope you like it.
Tip: By modifying the jQuery path '.popular-posts ul li .item-snippet' you can apply the same technique to other text-ill-cutting gadgets, too.
Click on a single comment to hide/show its text
19 comments:
thanks. but how to set the snippet length?
@Matt Morales
Hi, you can only (easily) make the snippet shorter than default, which is about 150 chars.
For example, in the hack's code change:
var txt=$(this).text();
to:
var txt=$(this).text().substr(0,80);
...to limit the snippet to max 80 chars (cut at the last space before 81 characters).
MS-potilas,
Sorry for the newbie question, but how do I load jQuery?
@Seth Mason Hi,
edit template, find </head> and put for example this line somewhere before the </head> line:
<script src='http://code.jquery.com/jquery-latest.js' type='text/javascript'></script>
I was a bit lazy writing this article and omitting that bit of info :)
@MS-potilas Got it. Also read you can load jQuery directly from Google by using this: <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> Supposedly faster. What do you think about loading it this way?
@Seth Mason That works also. I'm not familiar with the different versions of jQuery, loading speed, etc., should study those some day...
Can you make the snippet longer? @MS-potilas
@timslatter.com Unfortunately no. The template gives us only the certain length, and we can easily only cut it using javascript.
Nice share...
How to reduce or enlarge a thumbnail size?
@Kang Ismet
Hi, I wrote an article about that, see Resize Blogger popular post thumbnails. Thanks for the idea. :)
I have just added the extra HTML/Javascript in my sidebar but now, when i try to like some post on facebook, the text from the snippet just come like the code ... the code itself apears. And no text from snippet. PLease help me.
@pcgametv
Hi, you should use HTML/Javascript gadget, not text gadget. Or you can install the code in the template, before </body> if the gadget does not work for some reason.
hello.
I would like to change the ... to an arrow or some kind of unicode. Is that possible?
Thank you so much.
@agus
Hi, yes it is possible. Locate '...' from the source, and replace the contents inside ' and ' with whatever you want. Unicode arrow for example: change '...' to '\u21e8'.
@MS-potilas
Thanks brother It works great with blog posts also really it helped me a lot
coucou
bonne année, et merci pour cette astuce !
we are offering loans at the 2% interest rate. Our loan is safe and secure, for more information and applications, please contact us via email: bullsindia187@gmail.com or whats-app: +918130061433, Our services include the following: * Truck loans *
DO YOU NEED A FINANCIAL HELP? ARE YOU IN ANY FINANCIAL CRISIS OR DO YOU NEED FUNDS TO START UP YOUR OWN BUSINESS? DO YOU NEED FUNDS TO SETTLE YOUR DEBT OR PAY OFF YOUR BILLS OR START A GOOD BUSINESS? DO YOU HAVE A LOW CREDIT SCORE AND YOU ARE FINDING IT HARD TO OBTAIN CAPITAL SERVICES FROM LOCAL BANKS AND OTHER FINANCIAL INSTITUTES? HERE IS YOUR CHANCE TO OBTAIN FINANCIAL SERVICES FROM OUR COMPANY. WE OFFER THE FOLLOWING FINANCE TO INDIVIDUALS- *COMMERCIAL FINANCE
*PERSONAL FINANCE
*BUSINESS FINANCE
*CONSTRUCTION FINANCE
*BUSINESS FINANCE AND MANY MORE:
FOR MORE DETAILS.CONTACT ME VIA.
Contact Our Customer Care:
EMAIL: :bullsindia187@gmail.com
(CALL/WHATS APP) :+918130061433
Our services... Guaranteed 100%
See the hack to make the 'Post a Comment' link bigger.
Post a Comment