New Blogger Conditional Widget Niggle
I first noticed this problem almost immediately after the Blogger Beta went live with the Edit HTML availability, but assumed either I wasn't reading the documentation correctly, or that it just hadn't been implemented yet and would eventually. But I still can't get this to work, so someone correct me if they have and can spot where I'm going wrong.
The issue is widgets should be 'conditional' via their page type, meaning they should have the ability to specify what pages they appear on. According to the documentation, this is an option.
From Page Elements Tags for Layouts
A widget may have the following attributes:
* id - (Required) This may contain letters and numbers only, and each widget ID in your template should be unique. A widget's ID cannot be changed without deleting the widget and creating a new one.
* type - (Required) This indicates what kind of a widget it is, and should be one of the valid widget types listed below.
* locked - (Optional) Can be "yes" or "no," with "no" as the default. A locked widget cannot be moved or deleted from the Page Elements tab.
* title - (Optional) A display title for the widget. If none is specified, a default title such as "List1" will be used.
* pageType - (Optional) Can be "all," "archive," "main," or "item," with "all" as the default. The widget will only display on the designated pages of your blog. (All widgets display on the Page Elements tab, regardless of thier pageType.)
But everytime I try it, when the template is saved the pageType entry is just discarded.
But after saving the template, the pageType attribute is discarded without any error message reported.
Now before someone points this out, there is 'kind of' a workaround. You can wrap the contents of the widgets main includeable with conditional data tags so the content only displays on certain pages, but it is only a workaround. First off it's more involved, and second and more importantly, this only keeps the content of the widget from displaying on the page, but the widgets 'outer shell' will still generate. And many of the templates have default settings for borders/margins etc for a widget that will needlessly display in that situation.
So has anyone else got it to work? Or is it like I think and not working as advertised?
Post a Comment
11 comments:
Very interesting, Kirk. I've not got round to trying that pageType attribute yet - still trying to understand it all at a much lower level, as you know! But it's telling that the attribute gets stripped out whenever you try to save the template.
I've noticed the Blogger documentation is far from complete - lots of missing stuff from their "comprehensive" list of data tags for instance. So it doesn't surprise me that the mismatch can work the other way too, that they've documented something that doesn't work (yet?).
In general documentation often seems to lag behind the actual product, which is not surprising I guess, but still a shame. Of course it's early days yet for New Blogger and hopefully it time it'll all fit together.
Meanwhile, yes it is frustrating for those of us trying to work out how things work. Good job you like tinkering and figuring!
did u noticed the new tool of google:
http://code.google.com/p/habari/
yeah, it's frustating with the lack of documentation, i've tried to figure out pageType='all' almost 3 hours ! and there is NO 'all' for pageType ! it's 'index' !
so, i haven't tried this, is it possible to include the old classic template tag to the new one ?
i mean using <ItemPage> tag sort of thing ?
and i surely waiting forward for the 'workaround' you mentioned ;)
@efendi
Well, you got to realize that there are 2 different ways (supposedly) to use pageType. The one I'm referring to is specifically using it as an attribute for a widget tag to make it conditional. Which is the only one I can't get to work, and the only one that help file I linked to is supposed to apply to.
The OTHER pageType is a global data variable as listed here
which I have no problem using.
There does seem some debate between the two as whether the main page should be referred to as 'main' (what the widget pageType says) or as 'index' (what the global pageType says). All is easy enough, don't use anything and it will be on all.
And no, you can't use [ItemPage] tags, but you can use their equivalent.
[b:if cond='data:blog.pageType == "item"']
Whatever you need on the item page here
[/b:if]
Is the equivalent of [ItemPage] from Old Blogger (I'm using [ because I don't want to escape the tags properly because I'm lazy) .
Those work as advertised. If you want something on all pages, use nothing, the other values are index, item, and archive.
That's really the workaround I was talking about, using those conditional tags at the start and end of a widgets main includeable and the content of that widget will only display on those pages.
The reason why that isn't always good enough is, even tho the content of the widget won't display, all the opening and closing divs for the widget will (what I referred to in the post as it's outer shell)..and many layouts have default margins...or maybe borders..or something that will then display when they aren't wanted. Quick example, if your css has built in to add a border along the bottom of each sidebar widget, then doing the workaround would hide the contents on the correct pages, but still an empty space and a border would show up.
While if the widget pageType worked per the help file, one would presume that NONE of the widget code would get rendered, and solve that issue. Plus it would be easier when an entire widget needs to be conditional.
hm.. i c now, it's getting clear to me now, thx for the detail explanations.
i've tested it ;)
Ditto on bug. It's nice to know that I'm not the only one going crazy ;-). I'm beginning to think that I might hold off switching over until they get their shite together.
As long as we are on workarounds, why not just use a little javascript to hide or show these widgets?
It's a little tiresome, but not like no other workaround isn't ... :P
Yeah, if you are going to workaround, javascript would be as good as any.
It's not like this is a major/mission-critical thing. New Blogger still kicks Old Blogger's ass and takes it's lunch money.
Just would be nice if it worked as per the help file. I kept waiting for it to be enabled, and only posted about to verify that I wasn't doing something wrong. :-D
While we're at it, if they ever DO make it work, would make for a nice little selectable from the widget itself, little check boxes to check off to pick which pages it shows on. I may be pushing it now.
Awesome layout and great content here!
Can I ask how you put grahic images in your sidebar headings??
Thanks.
Gregg
www.GWEGGY.com
@phydeaux3
Could you share template xml file about your cool blog?
eg: http://phydeauxredux.googlepages.com/template.xml
Thanks a lot.
Thank you for this post. I've been trying to figure out the "workaround" all morning and it wasn't until you mentioned the includeable tags that I really figured out where to put the stuff. I kept getting errors. I agree that it would be nice if the pageType thing worked like Blogger says it does!
Post a Comment
0