Take a look at the home page of my site, Just Great Film, to see an example of this in action (click on images for full screen previews):
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg24soMD9_l6NdXrnS476C25sZipxu44bMDqjhwu2SSFYiWSKiVfHTI6fPrQSJXt7ckGtLJn4m6qIYzp1mjTpmTDCNJiZzJHG_i9bsy_BJyCkJ1SET6P4yk2EVecphGjTzKYMS38Yv6sbcY/s1600/just-great-film-home.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEideFAdvOdZ-2E_N_bP-ttKDadG0ou6Q4bOnMKQ2NzrtzlXZHQm4jjVuvLltRhzJddbZVqYz-C1O7w_nPm0If2KVvgzXwYEv5XyTXb51wLNbjFKGGgpqodu8jpWXFd-9hPyd_ykbkgsyEg2/s1600/just-great-film-item.png
Here's an easy way to restrict the display of a gadget to your blog's home page.
Back-up your existing template
Before making any changes to the HTML code of your Blogger template, it's advisable to make a backup of your existing, working template code, just in case you make a mistake when editing or accidentally save unwanted changes!To make a back-up of your Blogger template, simply go to Layout>Edit HTML in your Blogger dashboard and click the "Download full template" link near the top of the page.
This will prompt you to save your existing template file as an .XML document to your computer, which you could later upload if you need to restore your theme.
About "Conditional" Tags
"Conditional" template tags enable us to dictate the type of page in which the enclosed content can be displayed.In this example, we are restricting the display to the home page only, and will be using the following syntax:
<b:if cond='"data:blog.url==data:blog.homepageUrl"'>
<--Content to be displayed on home page appears here -->
</b:if>
Anything which appears between the <b:if> tags will be displayed only on the home page. We can add any HTML content between these tags, including Blogger template tags.
If you're confident editing the template code of your blog, you can adapt the code snippet to suit your requirements. Or read on for the simplest way to add this function to your template.
The simplest way to add a featured content section on your blog's home page
If you're using Blogger's new template editor (the new format for Blogger templates) you can add a featured content section in a few simple steps:Go to Layout>Edit HTML and locate the following section of code:
<div class='region-inner tabs-inner'>
<b:section class='tabs' id='crosscol' maxwidgets='1' showaddelement='yes'>
<b:widget id='Text2' locked='false' title='Some Title' type='Text'/>
</b:section>
<b:section class='tabs' id='crosscol-overflow' showaddelement='no'/>
</div>
Depending on whether you have installed a Page Links (or other) gadget, you may also see other gadgets housed within this sectionAdd the following lines (highlighted in red) to this section of your template code:
<div class='region-inner tabs-inner'>
<b:section class='tabs' id='crosscol' maxwidgets='1' showaddelement='yes'>
<b:widget id='Text2' locked='false' title='Some Title' type='Text'/>
</b:section>
<b:section class='tabs' id='crosscol-overflow' showaddelement='no'/>
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:section class='tabs' id='crosscol-homepage' showaddelement='yes'>
<b:widget id='HTML1' locked='false' title='Add title if you want to' type='HTML'/>
</b:section>
</b:if>
</div>- This will add an additional gadget section (beneath your tabbed page navigation, if present) in which you can add home-page-only content via the Page Elements section of your dashboard.
I've added a placeholder gadget in this code so you can easily identify the section when editing your gadgets in the Page Elements section of your dashboard. - Now preview your template: if all goes well, you should see your gadget appear in place above the posts without error and can proceed to save your template.
Geen opmerkingen:
Een reactie posten