Resources Page

Author: Webvanta

A single-page summary of everything in the Knowledgebase. One of many possible variations, this code is provided as part of your initial Webvanta site and is in the resources_page snippet.

This code iterates through each category, and for each one, it shows the Knowledgebase contents as follows:

  • Articles, if any (not links to external articles, but just articles that are part of the site)
  • For each of the other item types, all the Knowledgebase entries of that type (grouped by type)

In this example, items other than articles do not link to item pages, but instead link directly to external sites. You can change it to link to an item page by replacing w:url with w:path url="/item". Using the item page allows for commenting on each item.

<div id='resources_page'>
  <div style='float:right'><w:snippet name='addthis' /></div>
  <h1><span>Resources</span></h1>
  <!-- iterate through each category -->
  <w:kb:category:each> 
    <!-- if the category contains any items: -->
    <w:if_items>
      <h2><w:name /></h2>
      <div style='padding-left:  2em' class="item-box">
         <!-- if the item is an article:  -->
        <w:if_items type='articles'>  
          <h3>Our Articles</h3>
           <w:kb:item:each type='articles' category='current'>
            <div class='clearfix  resource_item'>
              <!--  
                is  the icon blank? if not, display it using the thumb rendition.
                renditions  are defined in 'design > config settings' under 'images  >  image.thumbnail.settings' 
               -->
              <w:unless condition='icon.blank?'><img src='<w:icon  rendition="thumb" />' class='listing-thumb'  alt='' /></w:unless> 
                <h4><w:name /></h4>
                <!--  reference for date formats:  http://www.webvanta.com/article/23155-formatting-dates/9363-displaying-database-items  -->
                <p>By <w:author />, Posted <w:created_at format='%m/%d/%y  %I:%M %p' /></p>
                 <w:description />
              <!--  display a link to the current item. 'url' refers to an item page. in  this case /kb/item -->
               <p id='continue_link'><a href='<w:path  url="/item" />'>Continue reading...</a></p>
            </div>
          </w:kb:item:each>
        </w:if_items>
        <!--  iterate through each resource type ('item type' type), exclude articles  and blog posts -->
        <w:kb:resourcetype:each  type='-articles,-posts'> 
             <!-- if there are items in the  current resource type as well as current category: -->
            <w:if_items type='current' category='current'>
              <!--  display the name of the current resource type -->
              <h3><w:name /></h3>
              <!--  iterate through each item of the current resource type and category  -->
              <w:kb:item:each  type='current' category='current'>
                <div class='clearfix  resource_item'>
                  <!--  if the item is a book: -->
                   <w:if_item type='Books' >
                     <w:kb:item>
                      <img src="<w:get name='book:image_url_medium' />" class='book_image' alt=''  />
                       <div class='book_text'>
                         <h4><w:get name='book:title'  /></h4>
                        <p><w:get name='book:subtitle'  /></p>                 
                        <p>By <w:author /></p>
                        <p>
                           <a href="http://www.amazon.com/exec/obidos/ASIN/<w:get  name='book:isbn10' />/<w:data name='aws_assoc_id' />" target="_blank" class='book_button'>
                             Buy From Amazon
                          </a>
                           List price: <w:get name='book:list_price' />  
                           Amazon price: <w:get name='book:our_price' />
                         </p>
                      </div>
                     </w:kb:item>
                  </w:if_item>
                   <!-- if the item is an  event: -->
                  <w:if_item type='Events'>
                    <w:kb:item>
                       <w:unless condition='icon.blank?'><img src='<w:icon  rendition="thumb" />' class='listing-thumb'  alt='' /></w:unless>
                     <h4><a href='<w:url  />' target='_blank'><w:name /></a></h4>
                      <w:description  />
                      <p>Dates: <w:get name='event:start_date' /> to <w:get name='event:start_date' /></p>
                      <p>Location: <w:get name='location:city' /> <w:get name='location:state'  /> <w:get name='location:country' /></p>
                    </w:kb:item>
                   </w:if_item>
                  <!--  if the item is something else besides an event or a book: -->
                  <w:if_item type='-Events, -Books'>
                     <w:kb:item>
                      <w:unless condition='icon.blank?'><img src='<w:icon rendition="thumb" />' class='listing-thumb' alt='' /></w:unless>
                      <h4 style='margin-bottom:3px'><a href='<w:url  />' target='_blank'><w:name /></a></h4>
                      <w:description  />
                     </w:kb:item>
                  </w:if_item>
                 </div>
              </w:kb:item:each>
           </w:if_items>
        </w:kb:resourcetype:each>
      </div>
    </w:if_items>
  </w:kb:category:each>
</div>