Declare javascript variable numPosts
This step is not absolutely necessary, but I like to declare the variables used in the whole page. Best place for this is in html head. So, edit template html, find </head> and add this before it:
<script type='text/javascript'> var numPosts = 7; </script>Default value is 7 posts per page. If there is already some javascript before </head>, you can also add only the var numPosts = 7; line before the </script> tag. Something like this (highlighted line is added, others are old lines):
// ... some old code here ... // ... some old code here ... var numPosts = 7; //]]> </script>Assign actual numPosts value in the posts widget
Ok, for this one you need to edit the html, again, and select Expand Widget Templates. Then find line:
<b:includable id='main' var='top'>and add after that these lines:
<script type='text/javascript'> numPosts = <data:numPosts/>; </script>And now we have the number of posts showing on the page in javascript variable numPosts.
Testing
To test that code works, find </body>, and add before that:
<script type='text/javascript'> document.title = document.title + " (viewing " + numPosts + " posts)"; </script>Again, if there is already some javascript there, before </body>, you can also add document.title... line there. Now when viewing the blog, window title should be "YourBlogName (viewing # posts), where # is the number of posts on page.
Click on a single comment to hide/show its text
16 comments:
hi admin, i want you help me to make script which count posts per author
thanks to answer
@Mr Admin
Hi, I did a HTML/Javascript gadget which counts blog posts per author and display them + avatars.
Pastebin
Copy the code from pastebin (use Raw link) and put it in HTML/Javascript gadget, and see if it does what you wanted, and if it needs any improvement. :)
Its good idea
thanks first to do it, but i want to make like author box, problem which i get that it show me all authors written posts in the blog not just the author of the read post, help me genuis MS-potilas
thanks to answer
@MS-potilas
I suggest to create a professional author box like one on wordpress using this script and adding author Description like on profile (blogger gadget) thanks to answer me@MS-potilas
i forget admin try to make theses script load fast thanks again@MS-potilas
@Mr Admin Ok now I see what you are after :) I think I could do something like Wordpress author box on Blogger. I will take some time, though. I'll get back when I have something ready.
Please, i have just one thing Mr-potilas make it easy for us to can customize it (it means in css part for avatar (.avatar{...}) for author-name (.author-name{...}) and for description (.descreaption{...}) thanks freind to respond to our request@MS-potilas
@Mr Admin
Hi Mr Admin,
I have now a demo ready, here: http://yabtb-demo1.blogspot.fi/2012/06/author-info-box-with-post-count.html.
Texts and styles can be customized. Works on single author and multi author blogs, on single author blog it is faster as it does not have to count all posts. But it was not slow on multi author blog, either.
Author box shows only when a single post is viewed, similar to Wordpress. For the main page it would take too long time to load for every post.
If you have any thoughts at this point, tell me, I could still make some changes before I start writing an article of this author box hack. :)
Thanks a lot MS-potilas for this good and precious work,
i have just one thing to discuss it, about description and other social links (youtube, yahoo etc...) i think here where script can load slowly with multiple authors, (i want you make it more professional it means make script call just introduction that every author write about him in his blogger profile) this thing make it too easy.
thanks to answer
@MS-potilas
I forget an important thing about
this sentense (who has written "post number" great posts on...) it's incorrect.
if post number = 0 or 1 post without plural sign (s)
and
if post number >= 2 post take plural sign s
please include it script
thanks to ask me about my suggestions i'm very happy thanks a lot MS-potilas
@MS-potilas
@Mr Admin
Thank you for your feedback :) I made additional code for singular and pluralis words, that is good addition. Descriptions per author can be fully customized, but in a multi user blog description can not contain scripts. In a single user blog you can put basically anything into the box. Well, hard to explain it here, I'll have to write the article.
Okey genuis MS-potilas@MS-potilas
Here's now something to try. Hope it suits you :) @Mr Admin
Okey i will see it@MS-potilas
Great tricks. I will try to put that on my blog. I'll be back for more review.
Thanks for sharing this information. This is really useful. Keep doing more.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Classes in Mumbai
IELTS Coaching in Mumbai
IELTS Coaching in Anna Nagar
Spoken English Class in Anna Nagar
See the hack to make the 'Post a Comment' link bigger.
Post a Comment