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

1774 6167

Last Topic: Template modules by Zielun on Feb 16, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1434 5088

Last Topic: Maintenance announcement by Nick on Feb 17, 2012

695 2912

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

174 740

Last Topic: Captcha images rendering slowly by ScottM on Feb 12, 2012

190 568

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

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

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012