Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-15 13:19:39

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Listing File Categories in groups

Is it possible to output files in groups of categories?

For example, a listing would be output like:

Category 1 -
My file ———————- 10mb —————— download link
File2 —————————2mb———————- download link

Category 2 -
File 3 ———————- 10mb —————— download link
Another file —————————2mb———————- download link

Thanks
Rich

Offline

#2 2009-11-15 13:37:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Listing File Categories in groups

richtestani wrote:

Is it possible to output files in groups of categories?

Yup! You need to enclose the category with an if_different tag.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2009-11-15 13:49:11

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Re: Listing File Categories in groups

oh nice! thanks!

Offline

#4 2009-11-15 15:45:24

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Re: Listing File Categories in groups

Continuing – Id also need a condition ending group tag.
So my structure looks like:

<txp:if_article_id id="45">
 <img src="/images/titles/volunteer-resources.png" />
  <txp:file_download_list sort="category" break="">
   <txp:if_different>
    <div class="section">
     <h2><txp:file_download_category /></h2>
    </txp:if_different>
      <txp:output_form form="file_download_list" />
     </div>
  </txp:file_download_list>
</txp:if_article_id>

so, when a new category starts, i output a div, then the category name.
when that category ends, i want to end the section.

the above outputs:

<div class="section">
  <h2>guidelines</h2>
	svncheatsheet-1.0.1.pdf
71.87KB
<a href="http://oh.krd.webhop.net/file_download/1/svncheatsheet-1.0.1.pdf">
download
</a>
</div>

Thank you card final2.pdf
448.58KB
<a href="http://oh.krd.webhop.net/file_download/3/Thank+you+card+final2.pdf">
download
</a>
				</div>



			<div class="section">
				<h2>images</h2>

				421729663_eacb60ee34.jpg
109.81KB
<a href="http://oh.krd.webhop.net/file_download/2/421729663_eacb60ee34.jpg">
download
</a>
				</div>

Id want a section to begin and end with each new category. How could I achieve this?
thanks
Rich

(edit: use bc.. for extended code blocks. -Els)

Last edited by els (2009-11-15 17:14:27)

Offline

#5 2009-11-15 16:36:08

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Listing File Categories in groups

richtestani wrote:

Id want a section to begin and end with each new category. How could I achieve this?

I’m not quite sure if I understand you, maybe the if_first_category and if_last_category tags might help you? If not please post the code you’d like to be output.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2009-11-15 17:25:20

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Listing File Categories in groups

if_first and if_last_category only work in a category_list I’m afraid… Though you could use that as well, see this TXP Tip for inspiration.

Otherwise you can use a workaround like this:

<txp:if_article_id id="45">
   <img src="/images/titles/volunteer-resources.png" />
   <div style="display:none;">
   <txp:file_download_list sort="category" break="">
      <txp:if_different>
         </div>
         <div class="section">
         <h2><txp:file_download_category /></h2>
      </txp:if_different>
      <txp:output_form form="file_download_list" />
   </txp:file_download_list>
   </div>
</txp:if_article_id>

You end up with an empty div at the start of the list, but at least it’s valid xhtml.

Offline

#7 2009-11-15 17:48:34

richtestani
Plugin Author
Registered: 2009-11-08
Posts: 128

Re: Listing File Categories in groups

Exactly!
Thanks Els!

Looking over txptips now – nice looking site.

Offline

Board footer

Powered by FluxBB