Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-07-03 18:07:18

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,058
Website

[solved x 2] tricky problem: format article custom fields into a table

TXP Freakin Geniuses start your engines.

I want to turn the following articles…

  1. title:article A / cf_vintage:2007 / cf_release:syrah / cf_action:dump
  2. title:article B / cf_vintage:2007 / cf_release:merlot / cf_action:hold
  3. title:article C / cf_vintage:2007 / cf_release:viognier / cf_action:dump
  4. title:article D / cf_vintage:2008 / cf_release:merlot / cf_action:drink-hold
  5. title:article E / cf_vintage:2008 / cf_release:syrah / cf_action:hold
  6. title:article F / cf_vintage:2006 / cf_release:syrah / cf_action:drink
  7. title:article G / cf_vintage:2008 / cf_release:viognier / cf_action:drink
  8. title:article H / cf_vintage:2009 / cf_release:viognier / cf_action:drink

into the following table.


Release 2006 2007 2008 2009
merlot - hold drink-hold -
syrah drink dump hold -
viognier - dump drink drink

the difficulty is that not every vintage has every release, so it’s hard to format empty cells.

Last edited by mrdale (2012-07-12 06:12:17)

Offline

#2 2012-07-03 20:46:30

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,383
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

Very nice :) Having a go at it now (but don’t hold your breath…)


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#3 2012-07-03 21:14:02

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 345

Re: [solved x 2] tricky problem: format article custom fields into a table

Perhaps this will fit your requirement. Not sure if I understand 100% your requirements:

<td>
<txp:custom_field name="cf_release"/>
</td>
<td>
<txp:if_custom_field name="cf_vintage" value="2006">
<txp:custom_field name="cf_action"/>
<txp:else/>-</txp:if_custom_field>
</td>
<td>
<txp:if_custom_field name="cf_vintage" value="2007">
<txp:custom_field name="cf_action"/>
<txp:else/>-</txp:if_custom_field>
</td>
<td>
<txp:if_custom_field name="cf_vintage" value="2008">
<txp:custom_field name="cf_action"/>
<txp:else/>-</txp:if_custom_field>
</td>
<td>
<txp:if_custom_field name="cf_vintage" value="2009">
<txp:custom_field name="cf_action"/>
<txp:else/>-</txp:if_custom_field>
</td>

<txp:rocks/>

Offline

#4 2012-07-03 21:28:36

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,058
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

almost, but the vintages are dynamic.

Offline

#5 2012-07-03 21:38:18

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,383
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

mrdale wrote:

almost, but the vintages are dynamic.

I think we need (a lot of) variables. (Still trying… not quite there yet.)


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#6 2012-07-03 21:41:48

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,058
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

or a lot of nesting… also working.

Offline

#7 2012-07-03 22:16:48

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,383
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

If the vintages are dynamic, the number of columns can vary, right? So you could have four columns, or twenty, or whatever. The table head can be done, but I don’t see a way to determine the number of cells needed for the content. I suppose you can’t use a custom field for each vintage?


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#8 2012-07-03 23:59:15

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,058
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

your assumptions are correct. I think I’m closing in on it tho.

Offline

#9 2012-07-04 03:50:38

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,058
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

OK, I did it, but I discovered that my old standby chh_if_data doesn’t work inside smd_each

Mighty chuffed… (requires smd_each)… see the solution here»

Last edited by mrdale (2012-07-04 04:05:59)

Offline

#10 2012-07-04 07:30:21

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,383
Website

Re: [solved x 2] tricky problem: format article custom fields into a table

mrdale wrote:

Mighty chuffed… (requires smd_each)… see the solution here»

Nice! I really like this kind of tag use :) I was halfway there last night, trying to do it without plugins. But I don’t think that is possible ;)


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

Board footer

Powered by FluxBB