I'm trying to display a News widget that shows only Entries tagged with a custom field defined for that entry itself i.e. news that matches that product.
So I have code with:
<mt:IfArchiveType type="individual">
<mt:Var name="foo" value="<$mt:EntryDataShortproductname$>">
<div class="widget-recent-entries widget-archives widget">
<h3 class="widget-header"><a href="<$mt:Var name="blog_url"$>news"><font color="948669"><$mt:Var name="$foo"$> News</font></a></h3>
<div class="widget-content">
<ul>
<mt:Entries category="<!-- 4 -->News" tag="<$mt:Var name="$foo"$>" days="99999">
<li><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></li>
</mt:Entries>
</ul>
</div>
</div>
but $foo is never displayed correctly in title and entries filtered by the $foo tag are not displayed (i.e. no entries are displayed at all).
If I leave out the $foo and use mt:EntryDataShortproductname directly then I get the title displayed correctly but not the entries (which is the important bit).
If I hard-code the text to a valid product name then title and entries are displayed correctly - I can't seem to get a working implementation using mt:Var though :(
Can anyone help or advise what I'm doing wrong here?
Many thanks.
Reported on Movable Type 4.25
You also can't have XML comments inside of attributes.
The is used to sort category order a la http://www.beausmith.com/mt/2009/05/ordering-categories.php
Are you saying that this will cause the category filtering of mt:Entries to fail? It doesn't.
Replacing the line you highlight with:
<mt:Entries category="<!-- 4 -->News" tag="Sekrit DS-I" days="99999">...works correctly (where "Sekrit DS-I" is the title of a tag with several entries)
Get rid of the comment and replace "<$mt:Var name="$foo"$>" with "<$foo>"
So your coding would change from:
<mt:Entries category="<!-- 4 -->News" tag="<$mt:Var name="$foo"$>" days="99999">
Into:
<mt:Entries category="News" tag="$foo" days="99999">
Tried that already (but with my ordering code) and it makes no difference :(
<mt:Entries category="<!-- 4 -->News" tag="$foo" days="99999">Or this either, for that matter:
<mt:Entries tag="$foo" days="99999">Oliver, try this:
1) <mt:Var name="foo" value="<$mt:EntryDataShortproductname$>">
with:
<$mt:EntryDataShortproductname setvar="short_product_name"$>
2) <mt:Entries tag="$foo" days="99999">
with:
<mt:Entries tag="$short_product_name" days="99999">
Aha - it works!
Thanks Mihai - had investigated setvar but the documentation didn't convince me I could use it in this context - http://www.movabletype.org/documentation/appendices/tags/setvar.html
And it works with my hacked '4 - News' category name too (only used as I couldn't get Entries sorted by a custom EntryOrder field as easily as I expected).
Thanks for the help.
You're welcome and glad it works!
It should have worked also with SetVar, but an elegant way is the one I've provided you.
As for the commented "4" I now understand it's role, though there is a plugin which could allow you to order categories.