Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-23 01:22:24

rawtext
Member
From: Massachusetts, USA
Registered: 2006-09-13
Posts: 21

if_different in article_custom Making a cat list with custom permlinks

Is it possible to use if_different in an article_custom form to output a list of all article
categories. Which means I would have to find a way for if_different to not repeat the same article category. I’m going for an custom permlink list of categories in a section.

The category list articles would only output the article category, which is why I’m thinking if_different can sift through all articles grabbing each category of every article.

What I’m doing for my section’s page’s article_list is displaying all articles on one page. The page is a restaurant menu using txp:title and 2 customfields for small and large prices. Make more sense? I’m hardcoding category named element id’s in my page and using article_custom to show the fields I need for every food article.

So I want to link to all those articles by headings (via internal links).
Which is why I need custom permlinks to my categories.

For my article_custom form with if_different. I’de use something like:
<code><a href=”/menu/#<txp:category1 />”><txp:category1 /></a></code>

Anyways, I hope I made things clear.

Is it possible or did I just totally overlook what if_different’s purpose is for.

Thank you for your time.

Offline

#2 2006-09-23 11:57:16

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

Re: if_different in article_custom Making a cat list with custom permlinks

I’m not sure I’m getting this. Can you give an example of what the output should look like?

Offline

#3 2006-09-23 16:36:14

rawtext
Member
From: Massachusetts, USA
Registered: 2006-09-13
Posts: 21

Re: if_different in article_custom Making a cat list with custom permlinks

Categories (my article_custom list that would use if_different to get the internal anchors in place)

  • <a href=”#calzones”>Calzones</a>
  • <a href=”#grill”>Grill</a>
  • <a href=”#another”>etc..</a>

And the following is what the cat list above will link to all on the same page. The tables display articles:
(title, custom1, custom2) = (3 cheese, 5.80, 9.80)

<table id=“calzones” class=“menuCat” summary=“Prices for Calzones”> <tr> <th scope=“col” class=“catTitle”>Calzones</th> <th scope=“col” class=“size”>Small</th> <th scope=“col” class=“size”>Large</th> </tr> <tr>

<td scope=“row” >3 Cheese</td> <td>5.80</td> <td>9.80</td> </tr> <tr> <td scope=“row” >Pepperoni</td> <td>6.00</td> <td>10.00</td> </tr> <tr> <td scope=“row” class=“detail”>Make Your Own w/ Cheese</td> <td></td> <td></td> </tr> <tr> <td scope=“row” >Each Additional Topping</td> <td>0.50</td> <td>0.75</td> </tr> </table>

<table id=“grill” class=“menuCat” summary=“Prices for Grilled food”> <tr> <th scope=“col” class=“catTitle”>Grill</th> <th scope=“col” class=“size”>Small</th> <th scope=“col” class=“size”>Large</th> </tr> <tr> <td scope=“row” >Chicken Stir-fry</td> <td>4.55</td> <td>5.65</td> </tr>

</table>

Offline

#4 2006-09-23 20:04:06

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,355
Website GitHub Mastodon

Re: if_different in article_custom Making a cat list with custom permlinks

First, start at your page template with

<txp:article_custom sortby="Category1,title"  />

which will provide the correct sort order.

Then, in your article form conditionally render a table row (or even a new <table> tag) for the heading whenever category 1 changes:

<txp:if_different>
<tr id="<txp:category1 />"><td><txp:category1 title="1" /></td><td>Small</td><td>Large</td></tr>
</txp:if_different>
<tr><td><txp:title /></td><td><txp:custom_field name"price_small" /></td><td><txp:custom_field name"price_large" /></td></tr>

The last line renders the usual menu entry. Might work…

Offline

#5 2006-09-24 02:39:06

rawtext
Member
From: Massachusetts, USA
Registered: 2006-09-13
Posts: 21

Re: if_different in article_custom Making a cat list with custom permlinks

wet thank you now I don’t have to hard code each table header in the page template if that works. But with if_different I was wondering if I could use it to display every category once by outputing /menu/#<txp:category1 > as a link that way it could make a list with links taking you to each food table on the menu. In other words I can’t get #category_name as the permlink or remove /category from the url and replace with #category_name

I wish I had this site live but at the moment it’s not. If someone would like me to pm me I think I can arrange a user name and password for you to see the site.

Thanks for all the help.

Offline

#6 2006-09-24 13:05:22

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

Re: if_different in article_custom Making a cat list with custom permlinks

You could try this in an article form (‘category_list’):
<code>
<txp:if_different><li><a href=”#<txp:category1 />”><txp:category1 title=“1” /></a></li><txp:if_different>
</code>
and on the page:
<code>
<ul><txp:article_custom form=“category_list” sortby=“category1” /></ul>
</code>
but I’m not sure if it will work because there are two txp tags inside the if_different statement. If not, handcoding appears to be the only option.

Offline

Board footer

Powered by FluxBB