Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: How to create a table cross-referencing content by cats on 2 axes
Thanks again, Stef! I think I worked it out week before last. Sorry I didn’t reply earlier— we were in the hospital having a new baby last week. ;)
For posterity, here’s what I’ve got going on, in simplified form.
First, from my .htaccess file, this is the line that gives me URLs for article lists (“regulations”) related to a specified topic and audience (“branch”):
RewriteRule ^(.*)/(.*)/regulation/(.*)/(.*)$ $1/index.php?s=$2&c=$3&branch=$4
So a URL would look like this for those pages:
{site_url}/{l10n_lang}/regulation/{topic}/{branch}
Next, here’s the form that displays that page (simplified and annotated):
<txp:adi_gps/> <!-- Get URL variables -->
<txp:if_category> <!-- We are in category context -->
<txp:variable name="topic"><txp:variable name="c"/></txp:variable> <!-- $topic = txp:category -->
...
<txp:smd_if field="txpvar:topic,txpvar:branch" operator="isused,isused"> <!-- Both $topic and $branch are specified -->
<hgroup>
<h1><txp:category name='<txp:variable name="topic"/>' title="1"/></h1> <!-- Title -->
<h2><txp:category name='<txp:variable name="branch"/>' title="1"/></h2> <!-- Subtitle -->
</hgroup>
...
<txp:article
limit="9999"
sort="posted asc"> <!-- Article list is automatically limited to $topic-specific articles, because of category context -->
<txp:if_article_category name='<txp:variable name="branch"/>'> <!-- Filter to $branch-specific articles -->
<!-- TXP article tags go here -->
</txp:if_article_category>
</txp:article>
...
Lastly, here’s the table on the section landing page that displays cells for each topic/branch combination:
<table id="topics-by-branch">
<thead>
<tr>
<th> </th>
<th colspan="6">##regulations_heading##</tr>
<tr>
<th>##fact_sheets_label##</th>
<txp:category_list
break=""
exclude="parent-branch"
parent="parent-branch"
wraptag=""> <!-- List the branches as table headings along X-axis -->
<th id="<txp:category/>">
<txp:category title="1"/>
</th>
</txp:category_list>
</tr>
</thead>
<tbody>
<txp:category_list
break="tr"
exclude="topic-parent"
parent="topic-parent"
wraptag="">
<txp:variable name="topic"><txp:category/></txp:variable> <!-- $topic = txp:category -->
<th id="<txp:category/>"><a href="<txp:site_url/><txp:l10n_get_lang/>/<txp:section/>/topic/<txp:category/>" rel="tag"><txp:category title="1"/></a></th> <!-- List topics as table headings on Y-axis -->
<txp:category_list
break=""
exclude="parent-branch"
parent="parent-branch"> <!-- New category list iterates branches for each topic -->
<txp:variable name="branch"><txp:category/></txp:variable> <!-- $branch = txp:category -->
<td headers="<txp:variable name="topic"/> <txp:variable name="branch"/>">
<txp:variable name="has_articles">
<txp:article_custom
break=""
category='<txp:variable name="topic"/>'
wraptag=""
limit="9999"
section='<txp:section/>'
sort="posted asc">
<txp:if_article_category name='<txp:variable name="branch"/>'>
<txp:article_id/>
</txp:if_article_category>
</txp:article_custom> <!-- Check that there are articles in this $topic and $branch context -->
</txp:variable>
<txp:if_variable name="has_articles" value=""> <!-- There weren't any -->
<txp:rvm_if_privileged> <!-- Logged-in site users can add one -->
<a class="edit-link" href="<txp:site_url/>textpattern/?event=article">Add Regulation Commentary</a>
<txp:else/> <!-- Regular site visitors see an empty cell -->
</txp:rvm_if_privileged>
<txp:else/> <!-- There was at least one article in this $topic and $branch context -->
<a
href="<txp:site_url/><txp:l10n_get_lang/>/<txp:section/>/regulation/<txp:variable name="topic"/>/<txp:variable name="branch"/>">
<txp:category name='<txp:variable name="topic"/>' title="1"/>: <txp:category name='<txp:variable name="branch"/>' title="1"/>
</a> <!-- Link to that article list -->
</txp:if_variable>
</td>
</txp:category_list>
</txp:category_list>
</tbody>
</table>
I only needed two plugins for the main functionality: adi_gps and smd_if; the rest is accomplished via vanialla TXP tags, with supplemental features powered by MLP and rvm_privileged. And it’s working.
I’d be willing to reconsider the method if this approach has dire performance implications. Does this look like it will cause any time-space anomalies?
Thanks again for your lucid and thoughtful support! I wouldn’t have gotten this far without your guidance.
warmest regards!
Edit: Fix code formatting.
Last edited by johnstephens (2011-04-18 15:35:41)
Offline
Re: How to create a table cross-referencing content by cats on 2 axes
Not to hijack but the other day I was trying to figure out how use <txp:adi_gps/> with a custom url and not coming up with an answer. And now I have a stunningly simple example.
Thank you.
Offline