Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-07-20 19:52:09

kritoke
Member
From: Florida
Registered: 2010-07-19
Posts: 26

Override a Section Listing

I am using a single form that I call to show either article listings or the full article. What I am trying to achieve is replacing a listing of image galleries (show the first image in the category and the category name below it). I have been successful to a degree, except that it repeats the output for however many times I have a gallery instead of outputting only once for the entire listing (so if I have two galleries like in this instance, it will output the same two pictures and captions twice). For the instance of the gallery list, it is only called via a link and not from an actual tag on a page to be displayed. Here is the simplified code I use (took out the div’s):

<txp:if_article_list>
<txp:if_section name="gallery">
<txp:upm_image image_id="7" type="thumbnail" url="92" class="shadow" /><br /><br />
<txp:upm_image image_id="7">
<txp:upm_img_category title="1" /></txp:upm_image>

<txp:upm_image image_id="17" type="thumbnail" url="138" class="shadow" /><br /><br />
<txp:upm_image image_id="17">
<txp:upm_img_category title="1" /></txp:upm_image>
<txp:else />

<! -- list page: display the short version -- >
<h2><txp:permlink><txp:title /></txp:permlink></h2>
<h4 class="subtitle">by <em><txp:author /></em> on <txp:posted format="%b %d, %Y" /> in <txp:section link="1" title="1"/> </h4>
<txp:excerpt />
<h4 class="subtitle"><a href="<txp:permlink />" title="Read the Whole Article" class="readmore">(read more)</a></h4>

<!-- This displays a separator image if it is not on the front page -->
<txp:if_section name="">
<txp:else />
<div class="divider"><txp:image id="1" /></div>
<br /></txp:if_section>
</txp:if_section>

<txp:else />

<!-- This Displays the full article -->

</txp:if_article_list>

Last edited by kritoke (2010-07-20 19:52:52)

Offline

#2 2010-07-20 19:59:03

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

Re: Override a Section Listing

I think the <txp:else /> after the upm_img tags is one too many?

Offline

#3 2010-07-20 20:04:26

kritoke
Member
From: Florida
Registered: 2010-07-19
Posts: 26

Re: Override a Section Listing

I am using that <txp:else /> to tell txp not to output anything else for the gallery section listing. If I remove that, it will output the article name and other info and will not output the listing for other sections. This form is for all my sections, not just for the gallery.

Offline

#4 2010-07-20 20:38:41

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

Re: Override a Section Listing

Yes, I now see I overlooked the second closing if_section tag. Did you examine the tag trace to see if it gives you any pointers?

Offline

#5 2010-07-20 21:00:53

kritoke
Member
From: Florida
Registered: 2010-07-19
Posts: 26

Re: Override a Section Listing

In the process of trying to debug everything, I moved the gallery out into its own form to help troubleshoot better, so it is called right before the excerpt form is called in the main page template. I ran the debugging mode and looked at the generated output. It is indeed doing what I thought it was doing, it is outputting the form for each article in gallery, even though the form is static. Unless I can figure out how to grab the first image in the image category and the image category number to pass to the plugin, I would have to figure out how to tell txp to call the form only once no matter how many articles exist in the section whenever someone tried to view a list of items in gallery section.

Offline

#6 2010-07-20 21:36:13

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

Re: Override a Section Listing

kritoke wrote:

I would have to figure out how to tell txp to call the form only once no matter how many articles exist in the section whenever someone tried to view a list of items in gallery section.

The easiest way is to take it out of your article form. Or else use <txp:if_first_article>.

Offline

#7 2010-07-20 22:08:13

kritoke
Member
From: Florida
Registered: 2010-07-19
Posts: 26

Re: Override a Section Listing

You sir are a genius. The first article tag did the trick, had no idea it existed. I put all the display code that I pasted here inside the txp tags and it resolved the issue.

Offline

#8 2010-07-20 22:17:00

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

Re: Override a Section Listing

kritoke wrote:

had no idea it existed.

Tag Reference :)

Offline

#9 2010-07-20 22:24:09

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Override a Section Listing

kritoke wrote (about Els):

You sir are a genius.

The genius part of that statement is correct. :)


Steve

Offline

Board footer

Powered by FluxBB