Friday, July 27, 2012

How to make a gadget only appear on the first page:

1   Add the gadget:  
Do this in the usual way.



2   Place the gadget

Drag-and-drop the gadget to the place where you want it.   It may be over or under your blog-posts gadget, or in a totoally different place.

A popular place for a gadget that is going to look like a "home page" would be in the Body section, just above the Blog Posts gadget, where "Test Gadget" is in this example:




3   Find the Gadget-ID  in the usual way.


4  Find the code for your gadget:

Edit your template  - and initially don't click expand widget templates.

Use your browser's text search tool (Edit / Find in Firefox, ctrl/F in Chrome) to look for the widget name that you noted in step 3.  Notice what comes after it.   In this example, it's the line for Blog1:
Click on the checkbox (so it's turned on)

After the expanded template has downloaded, find the widget name again.  This time it will look a bit longer (the exact details depend on what type of widget/gadget it is.

5   Add conditional formatting:

You need to put conditional formatting code around the code for the gadget - makings sure that it doesn't go around the code for anything else!  (which is why you noted what comes afterwards in step 4)

And to avoid leaving blank space where the gadget would have gone, you need to update a "hide" instruction to apply it to the gadget-id you noted in step 3.

The code to use is this.   Put the gadget-id instead of the XXX.

THE CODE FOR YOUR GADGET GOES IN HERE - ie the bold bit from the example above
The example above looks like this, when the code has been added:

6  Check that it's worked

Preview your blog before you save the changes:  check that the the widget is visible.

Save the template changes, and look at your blog.  Check that
  • The widget is on the first page
  • The widget is not seen when you look at an older page (eg one from your archive)
  • The other elements of your blog (other widgets, blog post titles, dates and contents) are all as you expect them - on the first screen, and on other screens too.

If anything is wrong with how your blog is working, go back to the template editor (Design > Edit HTML), and upload from the copy of your template that you made at the beginning of step 1.   This will let you blog work properly, while you figure out what went wrong.




Note:  in Blogger, the words "gadget", "widget", and even "page-element" all mean the same thing.  I generally use "gadget", because the Page Elements tab currently says "Add a Gadget".  But they're absolutely the same.

No comments:

Post a Comment