Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-02-24 12:35:14
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
linked custom_fields list
This might sound crazy at first, but I am wondering whether it is possible to output a list based on a custom field in a way that you can click on the list items. E.g. I have a custom fields for “Producers,” and I have 10 different producers. What should I do to call the info stored in the custom fields in a way that users can click on the producer of their choice and that takes them to a list of articles related to that particular producer? (I hope I am making sense…)
Thanks for any hint in advance!
Offline
Re: linked custom_fields list
Sounds like a problem for a plugin, and I don’t know of any that would do this. How about making a “Producers” category, then assigning each producer a category that is a child of the “Producers” category? Then you could get the list by using <txp:category_list parent="Producers" />
.
Code is topiary
Offline
#3 2008-02-24 13:56:54
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Re: linked custom_fields list
The problem is that the organization of the page has already used sections and categories for various (completely) different roles, and the producers cluster would only be a small part of information – excellent for custom fields that gathers a lot of tiny data alongside with it. It would also be great to have all the other custom field contents listed (names, etc.), so that it becomes a very useful and easy presentation for users who search for something (without actually filling in a search field – which is a problem when they don’t know the exact phrase…).
Anyway, I’ll give it a go and try to play arund with the idea, thank you!
Offline
Re: linked custom_fields list
It would be simple to make a plugin that returns a list of all distinct values in a custom field. The trick would be making each list item a link to an article list based on that custom field — maybe create a new section for this, that doesn’t contain any articles in itself, but has <txp:article_custom />
tags in the template to output lists based on custom fields. Sounds clunky, but might be possible.
Code is topiary
Offline
Re: linked custom_fields list
i’ve achieved something similiar in the past by using the custom field value as url variable.
in the article form:
<a href="/whatever/?producer=<txp:custom_field name="producer" />">See all productions by <txp:custom_field name="producer" /></a>
and then, in the page template you can use
<txp:chs_urlvar_default var="producer"> <txp:article /> <!-- here you put the default rendering --> </txp:chs_urlvar_default> <txp:chs_urlvar_exists var="producer"> <h2>All productionsy by <txp:chs_urlvar_exists var="producer" /></h2> <txp:asy_wondertag><txp:chh_article_custom producer="<txp:chs_urlvar_exists var="producer" />" /></txp:asy_wondertag> </txp:chs_urlvar_exists>
you’d need chs_ifurlvar and chh_article_custom
EDIT: oh you want a list of producers as well. guess that could be achieved by using in a page template
<txp:article limit="999" form="producerList" />
and in producerList
:
<txp:if_different> <a href="/whatever/?producer=<txp:custom_field name="producer" />"><txp:custom_field name="producer" /></a> </txp:if_different>
Last edited by sthmtc (2008-02-24 18:58:01)
Offline
#6 2008-02-24 15:18:02
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Re: linked custom_fields list
Wow! I’ll try this immediately :) Thanks ever so much!
Offline
#7 2008-02-24 15:30:25
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Re: linked custom_fields list
The link outputs this html:
<p><a href="/?producer=Ursa“>All products by Ursa</a></p>
Textile doesn’t like
<a href="/?producer=<txp:custom_field name="producer" />">All products by <txp:custom_field name="producer" /></a>
Is there a way to make it love it? :)
Offline
Re: linked custom_fields list
uhm, where did you put the link? in an article form or in the actual article itself?
Offline
#9 2008-02-24 15:58:01
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Offline
#10 2008-02-24 16:21:59
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Re: linked custom_fields list
Okay, remedied… :) But now the problem is that I’m using another word for “producer,” which has special characters… (i.e.: “Gyártó” – in Hungarian). Might that be a problem? Right now I’m getting errors like this:
The following tag caused an error: <txp:chh_article_custom Gyártó="<txp:chs_urlvar_exists var="Gyártó" /> -> Textpattern Notice: Unknown ...: id on line 605
Offline
#11 2008-02-24 16:23:17
- zoltandragon
- Member
- Registered: 2007-04-30
- Posts: 47
Re: linked custom_fields list
Oh, and for the producersList solution it doesn’t render anything… weird…
Offline
Re: linked custom_fields list
yeah i guess these special characters in the custom field name are problematic. can’t you rename it?
edit: same goes for the url variable. i bet you can’t use special characters there without running into problems. i’d strongly suggest renaming it, as it doesn’t appear anywhere except for the backend i think it shouldnt matter if you’d leave out the special chars.
Last edited by sthmtc (2008-02-24 16:48:12)
Offline