Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-08 04:47:36

cancath
New Member
Registered: 2008-07-08
Posts: 3

Custom field as link to filtered article list

I’d like to list all articles illustrated by any given artist. The artists’ names are stored in a custom field named “Artists” and are displayed in the original article listing.

How do I go about making the artist’s name a link to a new list of articles which that artist illustrated?

I can get a list using article_custom and restricting it to an artist I specify in the form, but I don’t know how to link from the original listing and filter by the artist selected. Thanks for any help!

Offline

#2 2008-07-08 08:34:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,727
Website

Re: Custom field as link to filtered article list

Perhaps try passing the artists name as a variable in the URL-Link, e.g. illustrations?artist=name_with_no_spaces.

Then on the page that shows the list of articles, use chs_if_urlvar to retrieve the value for artist and feed that using asy_wondertag or php (see example in wet’s gordian knot article) into the relevant attribute for your article_custom function. With the new parser billed for the forthcoming v4.07 of txp, tags in tags will work without such trickery but until then you need one of the two alternatives described above.

See this thread for an example along the lines described.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-07-08 12:01:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Custom field as link to filtered article list

cancath, not quite clear what you intend to have displayed where on your site or page, I see “the original article listing”, as you called it, a contradiction in itself, sorry. Do you need a list of all article contributions of the artist displayed right on the individual article’s page (article custom could create one by using customfieldname="artistname", surrounded by the mentioned asy_wondertag)

Or a single link to a list of articles which that artist created, but on a new page?

Last edited by uli (2008-07-08 12:03:47)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2008-07-08 14:25:48

cancath
New Member
Registered: 2008-07-08
Posts: 3

Re: Custom field as link to filtered article list

cancath, not quite clear what you intend to have displayed where on your site or page, I see “the original article listing”, as you called it, a contradiction in itself, sorry. Do you need a list of all article contributions of the artist displayed right on the individual article’s page (article custom could create one by using customfieldname=“artistname”, surrounded by the mentioned asy_wondertag)

Or a single link to a list of articles which that artist created, but on a new page?

Sorry for being unclear. I have a page which lists the articles by article title and artist name. I need each artist’s name to link to a list of articles which that artist illustrated, but on a new page. I’m trying to work with the asy_wondertag and chs_if_urlvar solution Jakob mentioned. Is that what I’ll need?

Last edited by cancath (2008-07-08 14:28:03)

Offline

#5 2008-07-08 15:36:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,727
Website

Re: Custom field as link to filtered article list

BTW: txp:article(_custom) can also filter by author if you were to create an author per artist and then assign ‘their’ articles to the respective author (which you can do with the multi-select at the bottom of the article pane). This could be viable if you only have a handful of artists but might be tedious if you have lots and lots of artists.

the chs_if_urlvar should work whether your link is to the current page or another one. In the linked example thread, “rachel rachel” could equally place a link to the movies by rating in another section or have “sort this page by rating/director/genre” buttons on the movie listing page.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-07-08 17:07:45

cancath
New Member
Registered: 2008-07-08
Posts: 3

Re: Custom field as link to filtered article list

Solved! Thanks for all the help. This topic was also very helpful in getting it working. I installed the plugins asy_wondertag and chs_if_urlvar .

Then, in the form I use for the list of articles and artists’ names, I used this to make the artist’s name into a link:

<txp:if_custom_field name="Artist">
<a href="/?a=<txp:custom_field name="Artist" />"><txp:custom_field name="Artist" /></a>
</txp:if_custom_field>

Next, in the page, I put the non-author-list stuff within a <txp:chs_urlvar_default> and added:

<txp:chs_urlvar_exists var="a">
<txp:asy_wondertag>
<txp:article_custom artist="<txp:chs_urlvar_echo var="a" />" limit="9999" form="artist" />
</txp:asy_wondertag>
<br />
</txp:chs_urlvar_exists>

And in the form “artist” I wrote:

<txp:asy_wondertag>
<txp:if_custom_field name="Artist" value="<txp:chs_urlvar_echo var="a" />">
</txp:asy_wondertag>
<txp:permlink><txp:title /></txp:permlink>

I initially had a closing </txp:if_custom_field>, but it came through to the html – does asy_wondertag stop Textpattern from recognizing that it’s still open, or am I misunderstanding how it should work? At any rate, it seems to be working now. Thanks again!

Last edited by cancath (2008-07-08 17:47:14)

Offline

Board footer

Powered by FluxBB