PixyBlog Lightbox   |   Basket   |   Login   |   Register
Pixy® Blog - Expose Yourself
  PixyBlog.comPhotoblog DiscussionPhotoblog Wiki
  • Log in / create account
Displaying related entries
  • Page
  • Discussion
  • View source
  • History

Displaying related entries

From PixyWiki

Jump to: navigation, search

Contents

  • 1 Overview
  • 2 Using the Macro
  • 3 Photoblog Example
  • 4 Output

Overview

For viewers of your blog it can be useful to display a list of related entries to a specific entry. This can be done in a couple of ways; either by using the Macro to display a list of related entries or by using the $model object.

Using the Macro

The macro is simple to include in your page templates and displays a list of the related entries. See the #showRelatedWeblogEntriesList documentation for details and an example.

Photoblog Example

For photoblogs, it can be useful to display a thumbnail image in-place of a text link.

Note: If you are on an entry page, as specified by the URL, then you can get the $entry object from the $model like so:

#if ($model.permalink)
    #set($relatedEntries = $model.getRelatedWeblogEntries($model.weblogEntry, 5) )
    <div>
    #foreach ($relatedEntry in $relatedEntries)
        #set($image = $relatedEntry.image)
        #set($thumb = $image.thumbSquare)
        <span>
            <a href="$url.entry($relatedEntry.anchor)" title="$relatedEntry.title"><img src="$url.photo($thumb.path)" width="$thumb.width" height="$thumb.height" alt="#showImageAltTag($image)" /></a>
        </span>
    #end
    </div>
#end

Otherwise, for non-entry pages, use the following code:

#set($entries = $model.weblog.getRecentWeblogEntries('nil', 1))
#foreach( $entry in $entries )

    #set($relatedEntries = $model.getRelatedWeblogEntries($entry, 5) )
    <div>
    #foreach ($relatedEntry in $relatedEntries)
        #set($image = $relatedEntry.image)
        #set($thumb = $image.thumbSquare)
        <span>
            <a href="$url.entry($relatedEntry.anchor)" title="$relatedEntry.title"><img src="$url.photo($thumb.path)" width="$thumb.width" height="$thumb.height" alt="#showImageAltTag($image)" /></a>
        </span>
    #end
    </div>

#end

Output

Using the demo blog the following is the output from the above code:

Retrieved from "http://wiki.pixyblog.com/Displaying_related_entries"
This page was last modified 10:35, 28 August 2009. This page has been accessed 218 times.
  • Privacy policy
  • About PixyWiki
  • Disclaimers
  • Powered by MediaWiki
  • Design by Paul Gu
Terms and Conditions | Privacy Policy | About | Contact us | Copyright © 2006-2008 Pixy® Ltd. All rights reserved.