<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html" />
  <link rel="self" type="application/atom+xml" href="http://forums.movabletype.org/atom.xml" />
  <id>tag:forums.movabletype.org,2011://24/tag:forums.movabletype.org,2008://24.7429-</id>
  <updated>2011-09-01T02:28:06Z</updated>
  <title>Comments for How to test if a container tag has any values to return?</title>
  
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.292</generator>
  <entry>
    <id>tag:forums.movabletype.org,2008://24.7429</id>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.movabletype.org/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=24/entry_id=7429" title="How to test if a container tag has any values to return?" />
    <published>2008-09-03T03:22:37Z</published>
    <updated>2008-09-03T07:05:12Z</updated>
    <title>How to test if a container tag has any values to return?</title>
    <summary>Say I want to show a block that contains a list of Pages, but I only want to show it if there are any pages (that meet my filter criteria, like author= , include_blog=, tags=) How would I test for...</summary>
    <author>
      <name>Boris Anthony</name>
      <uri>http://bopuc.levendis.com/</uri>
    </author>
    
    <category term="Design, Templates, &amp; Tags" />
    
    <content type="html" xml:lang="en" xml:base="http://forums.movabletype.org/">
      <![CDATA[<p>Say I want to show a block that contains a list of Pages, but I only want to show it if there are any pages (that meet my filter criteria, like author= , include_blog=, tags=)</p>

<p>How would I test for this? If I can at all... :)</p>
]]>
      

    </content>
  </entry>

  <entry>
    <id>tag:forums.movabletype.org,2008://24.7429-comment:6905</id>
    <thr:in-reply-to ref="tag:forums.movabletype.org,2008://24.7429" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html"/>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html#c6905" />
    <title>Comment from Su on 2008-09-02</title>
    <author>
        <name>Su</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>I can't test this right now, so you can be the guinea pig and let us know. It <em>should</em> work conceptually, but I don't know off-hand how picky the EntriesCount tag is going to be about its context.</p>

<p>    <br />
        <br />
            Your list output goes here.<br />
        <br />
            Otherwise, this will be shown.<br />
        <br />
    </p>

<p>You can, of course, just drop the Else.</p>

<p>We're hopefully taking advantage of the fact that as far as the data is concerned, pages are mostly just a special variety of entries(They're even in the same db table.) On the off chance this doesn't work, like if EntriesCount demands to be inside an Entries block(there's no PagesCount equivalent), you might try re-doing the Pages container as <a href="http://www.movabletype.org/documentation/appendices/tags/entries.html" rel="nofollow">Entries</a> with the class_type attribute set to "page" to force it to look at pages instead.</p>]]>
    </content>
    <published>2008-09-03T03:56:37Z</published>
  </entry>

  <entry>
    <id>tag:forums.movabletype.org,2008://24.7429-comment:6911</id>
    <thr:in-reply-to ref="tag:forums.movabletype.org,2008://24.7429" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html"/>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html#c6911" />
    <title>Comment from Boris Anthony on 2008-09-02</title>
    <author>
        <name>Boris Anthony</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Thanks Su.<br />
Your first guess works. :)</p>

<p>It doesn't quite solve my problem though because if mt:pages is empty, it won't spit out what's inside of it anyways (my "list"). What I want to hide is the title of the list, if there is no list to show...</p>

<p>eg:<br />
<br />
  List of pages<br />
  <ul><br />
    <br />
      <li></li><br />
  <br />
  </ul><br />
</p>

<p>Now I guess I'd have to put all that html that's outside the Pages container, inside of it and then, if there is a list to print, keep it from being iterated and repeated...</p>

<p>sorta like this:</p>

<p><br />
  <br />
   <br />
    List of pages<br />
    <ul><br />
  <br />
      <li></li><br />
  <br />
    </ul><br />
  <br />
  <br />
</p>

<p>anyways. in my current case, i only wan tto show the one most recent anyways so it's ok, but what if...</p>

<p><br />
Now I need to go find out why multi-blog include_blog= doesn't work in Dynamic templates... and how to fix that.</p>]]>
    </content>
    <published>2008-09-03T04:23:53Z</published>
  </entry>

  <entry>
    <id>tag:forums.movabletype.org,2008://24.7429-comment:6913</id>
    <thr:in-reply-to ref="tag:forums.movabletype.org,2008://24.7429" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html"/>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html#c6913" />
    <title>Comment from Boris Anthony on 2008-09-02</title>
    <author>
        <name>Boris Anthony</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>um... totally forgot about mt:PagesHeader and mt:PagesFooter</p>

<p>case closed. thnx to Su.</p>]]>
    </content>
    <published>2008-09-03T04:28:49Z</published>
  </entry>

  <entry>
    <id>tag:forums.movabletype.org,2008://24.7429-comment:6915</id>
    <thr:in-reply-to ref="tag:forums.movabletype.org,2008://24.7429" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html"/>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2008/09/how-to-test-if-a-container-tag.html#c6915" />
    <title>Comment from Gautam Patel on 2008-09-03</title>
    <author>
        <name>Gautam Patel</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>I have actually used this, _without_ the PagesHeader/Footer tags. Perhaps some of it does what you want?</p>

<p><br />
    <br />
    <br />
    <br />
    
        sort_order="descend"><br />
        <br />
        <br />
        <br />
        <br />
        <br />
        </p>

<p>        <br />
        <br />
        </p>

<p>        <br />
        <br />
        <br />
        <br />
        
            target="[MTPageDataExpiryDate format='%m/%d/%y']"><br />
        <br />
        <br />
        <a />" title=""><br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        &#133;[<a>#more"<br />
            title="Continue reading &quot;&quot;"><br />
                more<br />
                </a>]</p><br />
        <br />
        
            apply_macros="1"$><br />
        <br />
        <br />
        &nbsp;&#124;&nbsp;<br />
        <br />
        <br />
        <br />
        <br />
        <br />
        
            start="[MTPageDate format='%m/%d/%y']"<br />
            end="[MTPageDate format='%m/%d/%y']" end_adjust="60"><br />
        <br />
        <br />
        <a />" title=""><br />
            
            remove_html="1"$><br />
        <br />
        <br />
        <br />
        <br />
        &#133;[<a>#more"<br />
            title="Continue reading &quot;&quot;"><br />
            more<br />
        </a>]<br />
        <br />
        
            apply_macros="1"$><br />
        <br />
        <br />
        &nbsp;&#124;&nbsp;<br />
            <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
    <br />
    <br />
    

<p>    <br />
    /"><br />
    <br />
    <br />
    <br />
    <br />
    <br />
    This is my list<br />
    <br />
    <br />
    <br />
    <br />
    <br />
    </p>

<p></p>

<p>You could actually use this with the <pre>unique="1"</pre> attribute for entries and pages to generate a second list and then have the lists appear in two columns on a single page.</p>

<p>Not claiming this is great code or even terribly efficient, but it seems to do the job.</p>

<p>By the way, if you do copy-paste this code, you may have to remove some line-breaks I had to add in here.<br />
</p>]]>
    </content>
    <published>2008-09-03T07:05:12Z</published>
  </entry>

</feed>

