Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Market Website
I’m still not sure if I’ve understood your setup properly. If you have:
- An article per shop name, e.g. with article-url-title
sunny-sweets
with the corresponding stall numbers as a comma-separated list in a custom field, e.g.121, 124, 125
. - An article per stall name, e.g. with article-url-title
stall-121
with the corresponding article ID# of the shop article stored in a custom field, e.g.456
(where article 456 is Sunny Sweets).
Then you can cover both situations:
For the shop list, do something like:
<txp:article_custom section="shops" wraptag="div" class="container" break="" sort="Title asc">
<div class="entry shop">
<txp:permlink>
<div class="entry-image">
<txp:article_image class="thumbnail" escape="" />
</div>
<div class="dim"></div>
<i class="icon icon-lg icon-magnifier"></i>
<h3 class="entry-title"><txp:title /></h3>
</txp:permlink>
<div class="entry-meta">
<i class="icon icon-location-pin"></i>
Stall(s):
<txp:rah_repeat value='<txp:custom_field name="Stall" />' break="," wraptag="">
<a href="<txp:site_url />stalls/stall-<txp:rah_repeat_value />"><txp:rah_repeat_value /></a>
</txp:rah_repeat>
</div>
<div class="entry-desc">
<txp:excerpt />
</div>
</div>
</txp:article>
That gives you an entry per shop article with a list of linked stall numbers. It uses rah_repeat to iterate over the comma-separated list of stall numbers to generate the links. Tip: You can use rah_repeat_if_last
if you want to do lists like 121, 124 & 125.
If you use the article ID#s instead of stall numbers to link the articles, you can use txp:article_custom instead of rah_repeat (same principle as the example below).
For the stall list, you might do something like:
<txp:article_custom section="stalls" wraptag="div" class="container" break="" sort="Title asc">
<div class="entry stall">
<h3 class="entry-title"><txp:title /></h3>
<p>Stall tenant: <txp:article_custom id='<txp:custom_field name="stall_tenant" />'><txp:permlink><txp:title /></txp:permlink></txp:article_custom></p>
</div>
</txp:article_custom>
It’s not the most efficient organisation scheme:
a) because you need to update the shop name and the stall ids whenever things change. If that’s infrequent, it’s no big deal, just needs to be done methodically.
b) The article_custom within the article_custom is not the most efficient query mechanism. You could use a plugin like aks_cache or etc_cache to cache the respective blocks and reduce the server load to once only the first time around. After that it’s no longer an issue.
As I mentioned earlier, with glz_custom_fields and custom script field types, you could make the interlinking of shops to stalls and stalls to shops easier for the admin users. They can then simply select the corresponding stall numbers or stall tenants via a dropdown list.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Market Website
Thank you so much for your help and advice mate
Offline