Home > Tutorial > Show/Hide Gadgets on a Specific Page
Show/Hide Gadgets on a Specific Page
Posted on Sunday, October 31, 2010 by android apps market for tablests
It's about time to write a general tutorial on how to do this. I have written few tutorials in the past that use this concept, but it was specifically made for the Archive gadget and so on. But the need to generalize this concept is there, so here it comes!
I am sure there are lots of ways to do this. I'm going to write a tutorial on how I do things.The idea behind this tweak is simple, conditional codes. But it is very important for you to know which element you want to apply the conditions on. Check out this brief tutorial first on how you can identify your elements' ID or Classes. To examine the element, I excessively use Firebug. Firebug is a useful Firefox add-on that allows you to examine CSS styling of a certain page element before you style it. As I said before, this is my way of doing it. I know you can find the way to address your page elements by going to your template and usually find it in the widget area, but Firebug saves a lot of time.
So let's get started. In this tutorial, I will apply a text gadget below my header. So by default, this gadget will appear on every single page. But I want it to appear only on the homepage, so here's how.
I am sure there are lots of ways to do this. I'm going to write a tutorial on how I do things.The idea behind this tweak is simple, conditional codes. But it is very important for you to know which element you want to apply the conditions on. Check out this brief tutorial first on how you can identify your elements' ID or Classes. To examine the element, I excessively use Firebug. Firebug is a useful Firefox add-on that allows you to examine CSS styling of a certain page element before you style it. As I said before, this is my way of doing it. I know you can find the way to address your page elements by going to your template and usually find it in the widget area, but Firebug saves a lot of time.
So let's get started. In this tutorial, I will apply a text gadget below my header. So by default, this gadget will appear on every single page. But I want it to appear only on the homepage, so here's how.
Step 1:
Find out the class or ID that can be used to address your gadget.
In the Image above, I have used Firebug to inspect my gadget. And my text gadget can be address by the ID 'Text2'.
Find out the class or ID that can be used to address your gadget.
In the Image above, I have used Firebug to inspect my gadget. And my text gadget can be address by the ID 'Text2'.
Step 2:
In this step, we want to prepare our conditional code. First of all, you need to know the class or ID of the element that you want to address. We have already known this from our previous step. To show the text gadget only on our homepage, we should hide the text gadget in every other page except our homepage. This is the code that we will be using:
What the code implies is simple. In layman's term, it says, if the current address of the browser is not same as the address that is defined above in Line1, then execute the following command, which is to hide the element with ID 'Text2'. But if the current address of the browser is equal to the address that is defined in Line1, then do nothing.
So, if you've inserted your blog's URL in the first line, whenever you visit any other page, the element 'Text2' will be hidden. Simple right?
You might also be interested on how to hide a certain element from one particular page alone. Say I want my text gadget to be shown in all the pages, except for my static page. Then this is the command that I will be using:
In this case, the difference is '==' instead of '!=' in the above conditional code. In Layman's term, the code says, if the current address of the browser is same as the address that is defined above in Line1, the execute the following command, which is to hide the page element with ID 'Text2'. Otherwise, do nothing.
So this is how you can show or hide a certain gadget at a certain page. To hide only at one page, use '=='. To show only at one page, use '!='.
Minor note: The gadget above is addressed by its ID instead of class in CSS, so it is written as #Text2 in CSS. Say you want to address other page element, and instead of an ID, it is written class in Firebug, then you gotta use a dot (.) instead of a hash (#), some like this .Text2 in CSS. Usually a gadget is addressed by its ID, so hash (#) will do fine.
In this step, we want to prepare our conditional code. First of all, you need to know the class or ID of the element that you want to address. We have already known this from our previous step. To show the text gadget only on our homepage, we should hide the text gadget in every other page except our homepage. This is the code that we will be using:
<b:if cond='data:blog.url != "http://mylastaddresswasnotsonice.blogspot.com/"'>
<style>
#Text2{
display: none;
}
</style>
</b:if>
What the code implies is simple. In layman's term, it says, if the current address of the browser is not same as the address that is defined above in Line1, then execute the following command, which is to hide the element with ID 'Text2'. But if the current address of the browser is equal to the address that is defined in Line1, then do nothing.
So, if you've inserted your blog's URL in the first line, whenever you visit any other page, the element 'Text2' will be hidden. Simple right?
You might also be interested on how to hide a certain element from one particular page alone. Say I want my text gadget to be shown in all the pages, except for my static page. Then this is the command that I will be using:
<b:if cond='data:blog.url == "http://mylastaddresswasnotsonice.blogspot.com/p/static-page.html"'>
<style>
#Text2{
display: none;
}
</style>
</b:if>
In this case, the difference is '==' instead of '!=' in the above conditional code. In Layman's term, the code says, if the current address of the browser is same as the address that is defined above in Line1, the execute the following command, which is to hide the page element with ID 'Text2'. Otherwise, do nothing.
So this is how you can show or hide a certain gadget at a certain page. To hide only at one page, use '=='. To show only at one page, use '!='.
Minor note: The gadget above is addressed by its ID instead of class in CSS, so it is written as #Text2 in CSS. Say you want to address other page element, and instead of an ID, it is written class in Firebug, then you gotta use a dot (.) instead of a hash (#), some like this .Text2 in CSS. Usually a gadget is addressed by its ID, so hash (#) will do fine.
Step 3:
Now that we have prepared our conditional code, it is time for us to put it into action. But first, back up your template before making any changes. Then access your template's HTML.
Next, look for the line that says ]]></b:skin>. Paste your conditional code directly below it. Mine looks something like this:
Click on 'Save Template' and voila, your gadget will only show/hide on the page that you define. Happy trying.
Now that we have prepared our conditional code, it is time for us to put it into action. But first, back up your template before making any changes. Then access your template's HTML.
Next, look for the line that says ]]></b:skin>. Paste your conditional code directly below it. Mine looks something like this:
Click on 'Save Template' and voila, your gadget will only show/hide on the page that you define. Happy trying.
Category Article Tutorial
Powered by Blogger.
Blog Archive
-
▼
2010
(1682)
-
▼
October
(153)
- Info New Offer "HTC T9199" Smartphone Windows Mob...
- Complete info Specification "LG E900 Optimus 7" Wi...
- Amazing Book Blogs Gadget
- Show/Hide Gadgets on a Specific Page
- myTouch 4G specs
- 10? Motorola Tablet Coming with Gingerbread
- Image Too Large When Clicked On
- Motorola Droid X and Droid 2
- Motorola Droid 2 discontinued at Best Buy, two Dro...
- Shopping Amazon with Windowshop app for iPad
- Apple sues Motorola: A look at the complaints | Wi...
- Will HP, Dell, Sony answer 11-inch MacBook Air? | ...
- Apple iPhone Leapfrogs RIM BlackBerry in Smartphon...
- UK MPs question Google over Street View data breaches
- More details on Nexus Two surface
- Samsung SGH-a187 GoPhone - blue (AT&T)
- Find your polling place and follow the US Election...
- Find your polling place and follow the US Election...
- iPad Touchscreen freaks out & screens self-registe...
- How the New MacBook Air, Slate Define Apple and HP
- Price New CDMA Phone "LG 6400" With Wireles FM Su...
- Info Price Offer For New CDMA Phone "LG 6300" With...
- New in Google Maps for Android: Updated reviews, s...
- New in Google Maps for Android: Updated reviews, s...
- New MacBook Air Doesn�t Come With Adobe Flash
- MacBook Air�s Revolutionary New Display
- Bring Your Phone to Work Day: Managing Android Dev...
- Bring Your Phone to Work Day: Managing Android Dev...
- Price With Specification "LG 6210" CDMA Phone
- Price and Review New "LG 6160" CDMA Phone
- Gmail in mobile Safari: now even more like a nativ...
- Gmail in mobile Safari: now even more like a nativ...
- RIP Paul the Psychic Octopus
- Angry Birds Halloween HD for iPad
- Mobile Windows Phone 7 Info Specification "HTC Tr...
- Review About Andoid Smartphone "HTC Knight" The L...
- Images Can't Be Clicked After Adding Captions
- PBS for iPad - Watch Your Favorite PBS Shows
- iPad Screen Orientation Lock Switch to Mute Button
- Complete Info product Android phone "Motorola Droi...
- Info Price and Specification QWERTY Phone "Vitell ...
- Publish Post in Blogger Static Pages
- Review Apple MacBook Air 13" MC503LL/A Notebook
- Info Product Specification and Price "Vitell V711"...
- Info Price and Specification "Vitell V709 " Mobile...
- My iPad Keynote slideshow auto-advancing
- Exchange mail crashes & iPad Looping Reboot of Death
- Which is Better ? HP Slate 500 vs. MacBook Air
- Gigabyte GSmart G1305 Boston
- iMockups for iPad - Mobile Wireframing & Mockup app
- Voice Search in Russian, Polish, Czech and Turkish
- Voice Search in Russian, Polish, Czech and Turkish
- New Info About Android Phone "Lumigon" Handset f...
- download Application Blackberry Messenger 5.0.1.41
- New MacBook Air at $999 Only
- Samsung will use Bada OS in future televisions
- Android 2.2 On All Galaxy S Before
- How to Customize Links and Tabs on Pages Gadget
- Local notifications with iOS 4.2 for iPad
- We Doodle for iPad
- Info Complete Specification "LG Optimus 7Q" Produc...
- Info Android Phone "ZTE R750" Low Price
- TED for iPad - Education app
- Old camera connection accessorry compatibled with ...
- Steve Jobs takes shots at Android and BlackBerry
- Info Specification New Varian Multimedia Phone "No...
- Product Info "Samsung I8700 Omnia 7" Lates Windows...
- Different Background on Different Page
- Netflix on Wii Now
- New Xbox Kinect games line-up unveiled
- 2010 New AMD Radeon HD 6870 and HD 6850
- Hand-E-Holder holds your iPad in hand
- iPad screen goes black intermittently
- Info about Windows Phone 7 handset "Dell Veneu Pro...
- Complete InfoSpecification about WP7 handset "LG ...
- Adding an Already Added Gadget
- Info Specification and Price 3G Phone "Nexian Spee...
- Customize Tabs on Pages Gadget
- New Offer Phone Product "Nexian Hybrid NX-271D" T...
- Dedicated Separate Archive Page
- Virtual Static Page with Selected Posts in it
- An iPad Controls Self Driving Car
- Blogger Tips: Setting Up Homepage
- New Nokia Phones With Lavender Of Greatness
- Nokia N900 gets MeeGo boot option
- Nokia C5-03 Diumumkan Symbian^1 Layar Sentuh
- Complete Specification Info about "HTC 7 Surround ...
- Price With Feature Review TV Phone "SPC Boss 100"
- iPad locked up after trying to install iOS 4.2
- iA Writer for iPad
- Info Complete Specification "Nokia 5250" Music Phone
- Info Specification Product Windows Phone "Samsung ...
- Transformers Leader Class Starscream Review
- iOS4.2 Beta 3 for iPad Now Available
- Complete Info Specification about "HTC HD7" Window...
- Leak about New Android 2.2 (Froyo) Smartphone "HT...
- Complete Info Specification "HTC Mozart " The Wind...
- Info Complete Specification "HTC Desire Z" Androi...
- Cut the Rope Game HD Lite
- Apple Wireless Keyboard Layout can't match iPad
-
▼
October
(153)

