Back

Blog Title Search, Category Menu and Blog Tag Cloud

Description

This code example shows you how to create the blog title search, blog category menu, and blog tag cloud shown in the right hand column of the image below (inside the red rectangle).

This code goes along with the Blog Listing, Blog Detail, and Blog RSS codeshare code examples.

Code

<div class="BlogSearch">
  <form method="get">
    <input id="searchBox" type="text" name="blogSearch" placeholder="Search" ${esc.hash}if(${esc.dollar}blogSearch!= '') value="${esc.dollar}!{blogSearch}"${esc.hash}end />
    <input type="submit" value="Find" />
    <input type="hidden" name="search" value="true" />
  </form>
</div>
<!-- end .BlogSearch -->
  
<script type="text/javascript">
  function focusOnSearchBox() {
    document.getElementById('searchBox').focus();
  }
  window.onLoad = focusOnSearchBox();
</script>



<style>
  ${esc.hash}if(${esc.dollar}UtilMethods.isSet(${esc.dollar}catVar))
    li.${esc.dollar}catVar a{font-weight:bold;color:${esc.hash}d54c20;}
  ${esc.hash}else
    li.all a{font-weight:bold;color:${esc.hash}d54c20;}
  ${esc.hash}end
</style>

<h3>Topics</h3>
<nav class="p5">
  <ul class="side-menu">
      <li class="all"><a href="/blogs/index.dot">Most Recent</a></li>
    ${esc.hash}foreach(${esc.dollar}con in ${esc.dollar}categories.getChildrenCategoriesByKey("topic"))
      <li class="${esc.dollar}con.categoryVelocityVarName"><a href="/blogs/index.dot?cat=${esc.dollar}con.categoryVelocityVarName">${esc.dollar}con.categoryName</a></li>
    ${esc.hash}end
  </ul>
</nav>

<h3 class="border-bottom">Tags</h3>
<nav class="tag-cloud p3">
  ${esc.hash}set(${esc.dollar}tagCloudNoStyles = "true")
  ${esc.hash}tagCloud("Blog" '/blogs/index.dot' 20)
  <div class="clear"></div>
</nav>���

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor