We have a cross links template that lists the entries with the same tag as the current entry. Thing is, there are 6 top level categories and all the entries within a given category with a matching tag cross link just fine. But say we had the tag "bacon" in entries in 2 different top level categories, they will not cross link to each other. We were expecting a global tag match in the blog, but it seems we are getting only tag matches within a top level category. Our code:
<mt:Entries lastn="1">
<mt:EntryIfTagged>
<mt:EntryID setvar="current_entry">
<mt:SetVarBlock name="related_tags">
<mt:EntryTags include_private="1" glue=" OR ">
<mt:TagName>
</mt:EntryTags>
</mt:SetVarBlock>
<mt:Var name="related_tags" strip_linefeeds="1" setvar="related_tags">
</mt:EntryIfTagged>
</mt:Entries>
<mt:If name="related_tags">
<mt:SetVarBlock name="list_items">
<mt:Entries tags="$related_tags" limit="15" include_subcategories="1">
<mt:Unless tag="EntryID" eq="$current_entry">
<mt:If tag="EntryDataSearch_url">
<li><a href="<mt:EntryDataSearch_url>"><mt:EntryTitle></a></li>
<mt:Else>
<li><a href="<mt:EntryLink>"><mt:EntryTitle></a></li>
</mt:If>
<$mt:Var name="items_found" value="1"$>
</mt:Unless>
</mt:Entries>
</mt:SetVarBlock>
<mt:If name="items_found">
<div class="xnav">
<h2>Cross Links</h2>
<ul>
<$mt:Var name="list_items"$>
</ul>
</div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
xLinkColors();
});
</script>
</mt:If>
</mt:If>
Since we were using include_subcategories I figured maybe it's category based. So I grabbed a category listing and used Category to specifically point to each category in my Entries:
<mt:Entries lastn="1">
<mt:EntryIfTagged>
<mt:EntryID setvar="current_entry">
<mt:SetVarBlock name="related_tags">
<mt:EntryTags include_private="1" glue=" OR ">
<mt:TagName>
</mt:EntryTags>
</mt:SetVarBlock>
<mt:Var name="related_tags" strip_linefeeds="1" setvar="related_tags">
</mt:EntryIfTagged>
</mt:Entries>
<!-- cross category debug -->
<mt:SetVarBlock name="topcats">
<mt:Categories glue=" AND " strip_linefeeds="1">
#<$mt:CategoryID$>
</mt:Categories>
</mt:SetVarBlock>
<!-- end cross category debug -->
<mt:If name="related_tags">
<mt:SetVarBlock name="list_items">
<mt:Entries tags="$related_tags" category="$topcats" limit="15">
<mt:Unless tag="EntryID" eq="$current_entry">
<mt:If tag="EntryDataSearch_url">
<li><a href="<mt:EntryDataSearch_url>"><mt:EntryTitle></a></li>
<mt:Else>
<li><a href="<mt:EntryLink>"><mt:EntryTitle></a></li>
</mt:If>
<$mt:Var name="items_found" value="1"$>
</mt:Unless>
</mt:Entries>
</mt:SetVarBlock>
<mt:If name="items_found">
<div class="xnav">
<h2>Cross Links</h2>
<ul>
<$mt:Var name="list_items"$>
</ul>
</div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
xLinkColors();
});
</script>
</mt:If>
</mt:If>
That resulted in this error:
An error occurred publishing category '2': Publish error in template 'Landing Page': Error in <mtInclude> tag: error in module Cross Links - Landing Page: Publish error in template 'Cross Links - Landing Page': Error in <mtIf> tag: Error in <mtSetVarBlock> tag: Error in <mtEntries> tag: You have an error in your 'category' attribute: #46 AND #47 AND #21 AND #31 AND #2 AND #98 AND #105 AND #32 AND #51 AND #25 AND #26 AND #24 AND #7 AND #1 AND #29 AND #108 AND #27 AND #35 AND #34 AND #33 AND #22 AND #110 AND #6 AND #4 AND #53 AND #106 AND #42 AND #36 AND #49 AND #45 AND #5 AND #37 AND #48 AND #44 AND #38 AND #28 AND #3 AND #40 AND #39 AND #41 AND #50 AND #43 AND #9 AND #107 AND #52 AND #8
I researched and came to believe that was the character bug from MT 4.2 so I upgraded to MT 4.32. That didn't fix my problem. I had also tried this with CategoryBasename instead of ID's to see if it was the #'s holding me up but no dice. I had also tried a similar approach where I kept include_subcategories and grabbed just the top level categories, but that yielded the same results.
So, is there a way I can get this template to match tags for entries that are not living under the same top level category as the current entry? I could do the cross linking manually with a widget set but that would be a big re-arch and a re-launch so I'd like to get this template working if I can.
Reported on Movable Type 4.3
If you check the docu for mt:Entries you will see that you need to use the category names instead of basenames (or ids).
So when you are building the topcats variable use the
mt:CategoryLabel tag.
There were some problems in case of Category Names containing spaces so you might need to adjust your categories to not to contain spaces.