Wednesday, February 24, 2010

Blogger Tips- Create Drop Down Menu For Labels

If you don't want labels to be shown up on your blog as a long list, just try the following code . It would help you to create a drop down menu for your labels.

Go to edit HTML section of layout and find following code(Please make sure that you have already defined labels)


<ul>
   <b:loop values='data:labels' var='label'>
     <li>
       <b:if cond='data:blog.url == data:label.url'>
         <data:label.name/>
       <b:else/>
         <a expr:href="data:label.url"><data:label.name/></a>
       </b:if>
       (<data:label.count/>)
     </li>
   </b:loop>
   </ul>
 Replace above selected of code with the following code snippet
 <br/>
<select
onchange='location=this.options [this.selectedIndex].value;'
style='width:200px; background-color:#fff; color:#000;'>
<option>Select a Label</option>
   <b:loop values='data:labels' var='label'>
      <option expr:value='data:label.url'><data:label.name/>
         (<data:label.count/>)
      </option>
   </b:loop>
</select>

Now Save Template. 
 
 
 
 

No comments: