Pages

Sunday, April 8, 2012

11

How to make Blogger sticky post using a gadget

I have this other sticky post hack, which uses real Blogger posts. But for some Blogspot blogs that may not be the best solution, so lets see how we can do the sticky post thing using a HTML/Javascript gadget. I did not find "full solutions" where the sticky post works like it should, i.e. displays only on the first page of the blog, but not on other pages. So here is one, by me.


Adding the gadget

Go to Design, Page elements. Click Add a Gadget (any link will do, we will move the gadget to proper place afterwards).


Write the text/html you want in your "sticky post", click Save. I suggest to not use any title, it helps the correct alignment when gadget is hidden.


Now drag the new gadget to top of blog posts, like this:


Save.

Hide the gadget on other pages than first

Open template html for editing. Before </head> add this:

<b:if cond='data:blog.url != data:blog.homepageUrl'>
<style type='text/css'>
div.main div.widget.HTML .widget-content { display:none; }
div.main div.widget.HTML { margin-bottom:-30px; visibility: hidden;}
</style>
</b:if>

Depending on your template you might have to change the value -30px to adjust the position of blog texts. -30px works for "Simple" template.

How to mimic a post in gadget html

Here's a "template" you can use in HTML/Javascript gadget contents to make the gadget have post-like title, spacing and body text.


This template works at least in "Simple" and "Awesome Inc." templates, probably in others, too. :)

[Hide comments] - [Show comments]
Click on a single comment to hide/show its text

11 comments:

Mary said April 8, 2012 at 8:54 PM

Nice. I usually advise people to use the post-editor to generate the HTML (ie start to create a post, apply the formatting etc, copy the HTML, but don't publish it).

MS-potilas said April 9, 2012 at 9:19 AM

@Mary C Hi, that is a good advice, the post editor has more formatting options than HTML/Javascript configuration window, and you can also upload images with it.

Noct said April 17, 2012 at 3:56 PM

First time visit here, thanks for your great tips.

Follow immediately.

Unknown said April 18, 2012 at 2:44 PM

Wow, this blog has everything anyone need to improve their blogs, Thanks.

Taufik Nurrohman said April 23, 2012 at 11:27 AM

Oh, God. This is easier than what I thought T_T

maralian said October 23, 2013 at 1:04 PM

Can't seem to make jump break work in html/Javascript gadget. Any ideas?

MS-potilas said October 24, 2013 at 9:00 AM

@maralian
You could have a part of the text in gadget, like


Sticky Title

Some text in the sticky post and some more text. But not all. Read more...


Last in the gadget is a link, which targets to a page (or post) in your blog, where you can write the rest of the text.

Another solution would be to use javascript to show/hide a part of the text, some instructions for example here:
Show/Hide Content with CSS and JavaScript
.

Miss Ten said July 7, 2015 at 6:38 AM

I'm using this sticky hack for my blog.
May I know how to create a border & different background color for the sticky note?

Roger H Charles said July 18, 2015 at 6:50 AM

Thank you for this. A big help. You are more than "Just another tips blog". Top of the heap.

Anonymous said December 27, 2015 at 11:25 PM

nothing is sticky on demo page lel

MS-potilas said December 28, 2015 at 12:56 PM

@Muhammad Nouman Khalid
The "post like" section on top titled 'Sticky "post" (but not a real post)' is the "sticky post". http://yabtb-demo1.blogspot.com/#HTML2

Post a Comment

Related Posts Plugin for WordPress, Blogger...
See the hack
for this dynamic
views icon: