bmc

Displaying entry posts within current category

Vote 0 Votes

Hello,
I want to be able to be able to write one piece of code in my "Entry" module that will be able to be used on all my blog entry pages regardless of the category.

I am trying to display the past 3 articles written within the same category of the Entry Post Page I am on.

For instance, at the bottom of this page http://audiophilereview.com/2010/11/test-2-homepage-post.html in the Related Articles and Content area nearly at the bottom, I want to display similar articles within this same category.

The code I'm using now to get what I have is as follows:

Related Articles and Content

Please be sure to read our other articles, including
">
and the ">
.


Is there anything like category="current" or something that I can use to pull from the same category the article is in?

Thank you!
Bryan

Reported on Movable Type 5

14 Replies

| Add a Reply
  • http://www.movabletype.org/documentation/appendices/tags/entries.html#related-entries-by-category

    You might replace "glue" with lastn="3" unique="1" and add code for mt:EntrySummary to display more than the entry links.

  • the post is geat ,thanksss

  • Yeah, this is great. What would I add in if I want to exclude the current entry from this display?

    On my Entry post page, I have a "Related Articles and News" area. I'd love to exclude the current post or the one I'm on from the list if possible.

    Any ideas on that?

    Thanks!

  • I just realized that is what the "unique" is supposed to do; filter out posts of those already on the page. I'm a little confused as to how to implement the mt:EntrySummary? How would you change this?

    <p>Please be sure to read our other articles, including the following: 
            <$MTEntryCategory setvar="entry_category"$>
            <MTEntries category="$entry_category" glue=", " lastn="3" unique="1">
            <a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a>
            </MTEntries>.
         </p>
    
  • <$MTEntryCategory setvar="entry_category"$>
    <MTEntries category="$entry_category" lastn="3" unique="1">
    <a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a>
    <mt:Include module="Entry Summary">
    </MTEntries>

  • This is great, but I am having trouble figuring out how to exclude the current entry from the Entry template. Since is implied on the Entry template, the current entry isn't wrapped in that tag, so the "unique" attribute does not work... it only works when wrapped is used more than once. Any suggestions?

  • Oops.


    This is great, but I am having trouble figuring out how to exclude the current entry from the Entry template. Since <mt:Entries> is implied on the Entry template, the current entry isn't wrapped in that tag, so the "unique" attribute does not work... it only works when <mt:Entries> is used more than once. Any suggestions for excluding the current entry within the Entry template? I have a list of the entries one every entry page. Thanks.

  • Replace unique=1 with offset=1

  • This is great, but I am having trouble figuring out how to exclude the current entry from the Entry template. Since <mt:Entries> is implied on the Entry template, the current entry isn't wrapped in that tag, so the "unique" attribute does not work... it only works when <mt:Entries> is used more than once. Any suggestions for excluding the current entry within the Entry template? I have a list of the entries one every entry page. Thanks.

  • Hi, shenews. That does not work... that just removes the most recent entry from the list.

  • Here's the code in question:

    <div id="left-arrow">
    <a href="#" onclick="$.galleria.prev(); return false;"><img src="<$mt:StaticWebPath$>themes/bb-theme/images/left-arrow.jpg" alt="previous image" /></a>
    </div><!--left-arrow-->
    
    

    <div id="middle">
    <ul class="gallery_demo_unstyled">
    <mt:EntryAssets lastn="10" tag="@gallery">
    <li<mt:if name="__first__"> class="active"</mt:if>>
    <img src="<mt:AssetURL>"
    alt="<mt:AssetLabel escape="html">"
    title="<mt:AssetLabel escape="html">" />
    </li>
    </mt:EntryAssets>
    </ul>
    </div>

    <div id="right-arrow">
    <a href="#" onclick="$.galleria.next(); return false;"><img src="<$mt:StaticWebPath$>themes/bb-theme/images/right-arrow.jpg" alt="next image" /></a>
    </div><!--right-arrow-->

    <div><img src="<$mt:StaticWebPath$>themes/bb-theme/images/clear.gif" height="30" width="500"/></div>

    <div id="entry-section-thumbnails">


    <div class="entry-section-thumbnail">
    <mt:EntryAssets tag="@hover"><img name="<$mt:EntryID$>" id="<$mt:EntryID$>" src="<$mt:AssetURL$>" alt="<$mt:EntryTitle$>" /></mt:EntryAssets>
    </div><!--entry-section-thumbnail-->


    <mt:entryid setvar="thisentryid">
    <$MTEntryCategory setvar="entry_category"$>

    <mt:Entries category="$entry_category" exclude="$thisentryid$" sort_by="field:display_order" sort_order="ascend" offset="1">
    <div class="entry-section-thumbnail">
    <a onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('<$mt:EntryID$>','','<mt:EntryAssets tag="@hover"><$mt:AssetURL$></mt:EntryAssets>',1)" href="<$mt:EntryPermalink$>"><mt:EntryAssets tag="@thumb"><img name="<$mt:EntryID$>" id="<$mt:EntryID$>" src="<$mt:AssetURL$>" alt="<$mt:EntryTitle$>" /></mt:EntryAssets></a>
    </div><!--entry-section-thumbnail-->
    </mt:Entries>


    </div><!--entry-section-thumbnails-->


  • Sorry, I no longer seem to know what you're trying to do.

    "excluding the current entry within the Entry template" seems to swear at itself!

  • :) Thank you for your help.

    Here's a page:
    page example

    This is an entry. There are five entries in the category. The entry page should show large image from the entry, small hover image for the entry, and small images for each of the other four entries in the category.

    If anyone can help, I'd appreciate it! I've been struggling for nearly 12 hours now!

  • In case anyone else runs into this issue, here's what I did to get it to work:

    <mt:EntryCategory setvar="entry_category"$>
    <mt:EntryID setvar="entry_id"$>
    
    

    <mt:Entries category="$entry_category" sort_by="field:display_order" sort_order="ascend">
    <mt:If tag="entryid" ne="$entry_id">
    ENTRY-SPECIFIC TAGS GO HERE
    </mt:If>
    </mt:Entries>

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

137 479

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

238 797

Last Topic: Manifest Schema Compatibility Issue When Restoring Blog by Matt on Oct 17, 2012

1858 6594

Last Topic: Categories and Basename Publishing Issues by e21media on Oct 25, 2012

88 307

Last Topic: absolute publish date in Manage Entries screen by .mau. on Apr 18, 2012

1488 5347

Last Topic: Anti-cloning by .mau. on Oct 29, 2012

732 3093

Last Topic: Blog moved server - now users cannot access blog? by mowgs on Oct 30, 2012

89 317

Last Topic: How to "pretify" a url in htaccess with a few wildcards by Caio on May 30, 2012

183 771

Last Topic: Commenting with TypePad by Rob Ferrara on Oct 17, 2012

212 680

Last Topic: Does MT-Approval work in MT5? by DLpres on Sep 25, 2012

27 100

Last Topic: Upgrading MT by Caio on Oct 15, 2012

49 224

Last Topic: Movable Type 6 Ideas by Caio on May 28, 2012

65 248

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012