user-pic

Using AND with tags e.g. tag="foo AND bar"

Vote 0 Votes

I can never seem to get the AND command working...this doesn't work:

  <mt:Var name="starterlimit" value="999">
  <mt:Var name="startercount" value="0">
  <$mt:PageDataShortProductName setvar="short_product_name"$>
  <mt:Entries tag="@starter AND $short_product_name" sort_by="field:entrypriority" sort_order="descend">
   <mt:If name="startercount" lt="$starterlimit">
     <mt:setvarblock name="startertitle"><a href="<$mt:EntryPermalink$>"><mt:EntryTitle></a></mt:setvarblock>
     <mt:setvarblock name="starterlist{$startertitle}"><mt:EntryDataEntryPriority></mt:setvarblock>
     <$mt:Var name="startercount" op="++" setvar="startercount"$>
    </mt:EntryIfTagged>
   </mt:If>
  </mt:Entries>

This does:

  <mt:Var name="starterlimit" value="999">
  <mt:Var name="startercount" value="0">
  <$mt:PageDataShortProductName setvar="short_product_name"$>
  <mt:Entries tag="$short_product_name" sort_by="field:entrypriority" sort_order="descend">
   <mt:If name="startercount" lt="$starterlimit">
    <mt:EntryIfTagged tag="@starter">
     <mt:setvarblock name="startertitle"><a href="<$mt:EntryPermalink$>"><mt:EntryTitle></a></mt:setvarblock>
     <mt:setvarblock name="starterlist{$startertitle}"><mt:EntryDataEntryPriority></mt:setvarblock>
     <$mt:Var name="startercount" op="++" setvar="startercount"$>
    </mt:EntryIfTagged>
   </mt:If>
  </mt:Entries>

Reported on Movable Type 4.3

4 Replies

| Add a Reply
  • It might be that you cannot supply a regular tag AND a sticky tag at once.

    Why aren't you simply using your second coding, which works?

  • I am using it...it's just frustrating not being able to use the simpler code. I'm trying to build product-specific stuff which relies on certain types of content combining with something that identifies the product e.g. @starter AND $product or $FAQ AND $product.

    Hopefully somebody might be able to confirm what affect the sticky tag or local variable has, if any, on tag="" constructs...

  • You might find this posting interesting:
    http://www.movabletips.com/2010/06/combining-tag-attributes-and-or-and-variables-in-movable-type.html

    (If you build the entire argument inside a 'setvarblock' tag first, then you can easily use the resulting variable as the argument. It might not be 100% elegant but at least all your selections will happen in one line of code which makes it easier to see what you are filtering for.)

  • Very interesting - thanks for the link and confirmation.

    Will try and post my updated code for future code-stumblers like myself.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

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

1428 5076

Last Topic: Stupid Question? How to make a static homepage by Jeremy on Feb 3, 2012

694 2908

Last Topic: Blogspot to Movable Type by sdude on Feb 8, 2012

84 291

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

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 565

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 716

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