Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-11-09 15:26:07
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
No Images in a Category
I’m trying to figure out a way to output some default text if no images are found for a particular image category. Here is the relevant part of my page code:
<txp:article section="artists" pgonly="1" />
<txp:asy_wondertag>
<txp:wet_for_each_image category="<txp:custom_field name="artistname" />">
<txp:upm_image form="thumb_click" image_id="{id}" />
</txp:wet_for_each_image>
</txp:asy_wondertag>
What I’d like to do is output something like “There are no images for this artist” if the above code has no output. I tried using the chh_if_data plugin, but it doesn’t seem to appreciate all the tags within tags stuff in this case, or the asy_wondertags maybe.
Any suggestions? Thanks!
Last edited by sparkybarkalot (2007-11-09 15:29:06)
Offline
#2 2007-11-09 16:46:49
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No Images in a Category
Where did you place the chh_if_data tags?
Offline
#3 2007-11-09 17:10:14
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
Els: I tried placing them just OUTSIDE the asy_wondertag tags and I also tried placing them just INSIDE the asy_wondertag tags.
Offline
Re: No Images in a Category
Is that custom_field used for anything else other than image category connection?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#5 2007-11-09 17:26:28
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No Images in a Category
chh_if_data doesn’t work if it is wrapped around more than one txp tag. Does it work if you wrap it around the upm_image tag?
Offline
#6 2007-11-09 18:23:56
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
Els: Thanks for working with me on this. That doesn’t seem to work either. I tried this, but the text output did not appear:
<txp:article section="artists" pgonly="1" />
<txp:asy_wondertag>
<txp:wet_for_each_image category="<txp:custom_field name="artistname" />">
<txp:chh_if_data>
<txp:upm_image form="thumb_click" image_id="{id}" />
<txp:else />
<p>no images</p>
</txp:chh_if_data>
</txp:wet_for_each_image>
</txp:asy_wondertag>
Any other thoughts?
Offline
#7 2007-11-09 20:46:28
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No Images in a Category
Hmm.. that must be because of the image_id="{id}". I may have found a (sort of) workaround, but I need to know a couple of things first.
What does this code of yours display exactly? A list of thumbnails for a category that has the same name as the custom field ‘artistname’?
And what is the url of such a page?
Offline
#8 2007-11-09 23:14:18
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
Els: Yes, you’re exactly right about what the code displays: it’s a list of thumbnails for a category that has the same name as the custom field ‘artistname’. Here is a URL on my testing server for one of those pages:
http://cmsdwg.dougfelton.com/artists/jacobus-baas
Offline
#9 2007-11-10 00:13:36
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No Images in a Category
Well, I’ve done some testing, and I would have found a workaround if this was about articles, but apparently chh_if_data doesn’t work with image tags. So I can’t help you.
But I’m sure that it can be done with php, so all you have to do is wait for a proper coder to come by and tell you how :)
Offline
#10 2007-11-10 00:46:25
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
Thanks very much for giving it a try Els. I appreciate it. I’ll keep working on it and post something back here if I get something. If anybody else has any ideas, let me know!
Offline
Re: No Images in a Category
Could you answer my question further up the thread?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#12 2007-11-12 16:48:37
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
thebombsite: I’m sorry I missed your question. The custom field is ONLY used for the image category connection.
Offline
Re: No Images in a Category
Sorry for taking so long but I had a slight problem which required the purchase of a new PC. :(
Anyway, the reason I asked is because if it is only used for that purpose, as you say, I presume that if an artist has no images then you can leave the field blank. If that is the case then there is an attribute for txp:custom_field called “default” which allows you to output a message if the field is empty. Does that help at all?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#14 2007-11-19 18:01:02
- sparkybarkalot
- Member
- Registered: 2004-10-13
- Posts: 43
Re: No Images in a Category
Ohhhh… yeah… that should be exactly what I’m looking for. I’ll go try it now. Thanks!
Offline
#15 2007-11-19 19:53:01
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: No Images in a Category
Jeez, Stuart, how do you know these things? You must have memorized TextBook ;)
But seriously, thanks for the tip, I hadn’t found that one yet.
Offline