Help - Search - Members - Calendar
Full Version: Mtrelatedentries To Show Only Subcategory?
Movable Type Community Forum > Using Movable Type > Categories and Entry Tags
Ivydionne
I'm using the MTRelatedEntries to show related links on entry archive pages. It works great, except I get both the top category, and the subcategory, when I only want the subcategory.

My categories are as follows:

Art
- pencil
- paint
- ink
- digital

So if I have an entry page in the "pencil" category, its actually tagged "art" and "pencil".

I use the code below (I use a thumbnail image as my link, entered into the Excerpt field, that's why that's there):

<MTRelatedEntries>
<MTEntries lastn="7">
<a href="<$MTEntryPermalink$>"><mt:EntryExcerpt /></a>
</MTEntries>
</MTRelatedEntries>



Instead of getting just other pencil sketch links, I get everything from the art category.

Any way (aside from dropping the "art" tag from all my entries) to get it to just pull in the subcategory?
justinmc
Would wrapping your entries tags in something like <mt:hasparentcateogry> work? That generally only produces sub categories. If you nest it just under the relatedentries tag, you should get the proper conditional logic.
Ivydionne
QUOTE (justinmc @ Mar 28 2008, 01:43 PM) *
Would wrapping your entries tags in something like <mt:hasparentcateogry> work? That generally only produces sub categories. If you nest it just under the relatedentries tag, you should get the proper conditional logic.



I get an error message: <mt:hasparentcateogry> is unrecognized when I try that. :-(

Am I perhaps missing another plugin?
Ivydionne
QUOTE (Ivydionne @ Mar 28 2008, 07:27 PM) *
I get an error message: <mt:hasparentcateogry> is unrecognized when I try that. :-(
Am I perhaps missing another plugin?



Ah, okay I had done a copy/paste from this page and there was a typo. Fixed it and tried again. This time it did save and publish, but instead of showing me only the matching subcat listings, all the listings disappeared.

Ivydionne
Okay, I've poured through pages and pages of forum posts, websites and blogs to find anything that might work. I've looked into other plugins and nothing seems to be the right fit. I'm at a loss here... I may have to pull this section from my site which is unfortunate b/c I thought it really added to the browsing experience.

Anyone have any other suggestions?

OtherNiceMan
QUOTE (Ivydionne @ Mar 28 2008, 08:27 PM) *
QUOTE (justinmc @ Mar 28 2008, 01:43 PM) *
Would wrapping your entries tags in something like <mt:hasparentcateogry> work? That generally only produces sub categories. If you nest it just under the relatedentries tag, you should get the proper conditional logic.



I get an error message: <mt:hasparentcateogry> is unrecognized when I try that. :-(

Am I perhaps missing another plugin?


Can you post your code, mt:HasParentCategory is a valid tag, it is part of the core so no plugin required.
Ivydionne
QUOTE
Can you post your code, mt:HasParentCategory is a valid tag, it is part of the core so no plugin required.



There was a typo in the tag which is why it generated an error message.

When I found and fixed it, I was using this code:

<MTRelatedEntries>
<mt:hasparentcategory>
<MTEntries lastn="7">
<a href="<$MTEntryPermalink$>"><mt:EntryExcerpt /></a>
</MTEntries>
</mt:hasparentcategory>
</MTRelatedEntries>


It didn't generate any errors, but when I refreshed the page ALL the related entry links disappeared.

OtherNiceMan
Try changing the order of the tags to


CODE
<mt:hasparentcategory>
<MTRelatedEntries>
<MTEntries lastn="7">
<a href="<$MTEntryPermalink$>"><mt:EntryExcerpt /></a>
</MTEntries>
</MTRelatedEntries>
</mt:hasparentcategory>


or

CODE
<MTRelatedEntries>

<MTEntries lastn="7">
<mt:hasparentcategory>
<a href="<$MTEntryPermalink$>"><mt:EntryExcerpt /></a>
</mt:hasparentcategory>
</MTEntries>
</MTRelatedEntries>
Ivydionne
Tried both of those options and the similar entries links disappeared altogether. sad.gif
Ivydionne
QUOTE (Ivydionne @ Apr 3 2008, 06:10 PM) *
Tried both of those options and the similar entries links disappeared altogether. sad.gif



No other recommendations out there?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.