movable type tag into variable
I want to get the entrycount of entries that are @events. I want to store that value in a variable because I want to use the value in a if statment later. I thought the following would work but no luck:
<$mt:EntriesCou开发者_开发知识库nt tag="@events" name='the_events'>
<mt:var name="event_count" value="$the_events">
Any idea how to get entriescount into a variable?
Try:
<mt:entries tag="@events">
<$mt:entriescount setvar="event_count"$>
</mt:entries>
And then:
<mt:if name="event_count" eq="1234">
[output if true]
</mt:if>
You should note that this is absolute minimum. By not including a lastn
or limit
argument on mt:entries
, this is subject to your Entry Listing Default blog setting. Add whatever you need to the loop to make it fit your actual requirements.
I'm also assuming this is in an index template, for simplicity. Both the Entries and EntriesCount tags are affected by template context, and may produce different output if you place this directly in a category template, for example.
精彩评论