Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-09-06 23:57:44

shadden
New Member
Registered: 2010-07-27
Posts: 8

Include all images in category instead of entering Image IDs

I am using Gallerific to create my galleries; at this point, I have to enter all the image IDs on the article page that I want to display in the gallery associated with each article.

I want to be able to just select an image category and have all the images in that category be shown in the gallery.

I read through the other topics on the forum and it seems like smd_gallery might work; the problem is that I have multiple gallery articles that all draw from one page template, and each gallery article needs to draw from separate image categories.

Is there a way to associate each individual article with a whole image category?

Thanks for any help anyone may be able to lend.

Offline

#2 2010-09-07 03:53:06

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Include all images in category instead of entering Image IDs

Hello,

Create a custom field called Gallery Image Category Name or something similar and enter the appropriate set of images category name in the field on the Content/Write page when you create each article. In your single article form, include something like this to generate your thumbnails.

<txp:if_custom_field name="Gallery Image Category Name"> <div id="thumbs" class="navigation"> <ul class="thumbs noscript"> <txp:smd_gallery category="?Gallery Image Category Name" sublevel="all" form="mysite_gallery" sort="name asc" /> </ul> </div> </txp:if_custom_field>

Create an appropriate form (mysite_gallery in the snippet above) for smd_gallery. You will also need a plug-in like upm_image to call the caption in that form.

Hope that gets you going.

Offline

#3 2010-09-07 11:56:03

shadden
New Member
Registered: 2010-07-27
Posts: 8

Re: Include all images in category instead of entering Image IDs

Thanks for the help; it’s not doing what it’s supposed to, however. Here’s the code I had before to call the gallery simply from the Image IDs:
<div id="thumbs" class="navigation"> <txp:article listform="gallery" form="gallery" sort="Posted asc" limit="1" /> </div>

And here’s how I reformatted it:
<txp:if_custom_field name="Gallery Image Category Name"> <div id="thumbs" class="navigation"> <txp:smd_gallery category="?Gallery Image Category Name" form="gallery" sort="Posted asc" limit="1" /> </div> </txp:if_custom_field>

What am I doing wrong? (smd_gallery is installed and activated).

Last edited by shadden (2010-09-07 11:57:04)

Offline

#4 2010-09-07 12:05:57

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: Include all images in category instead of entering Image IDs

Is it possible to leave spaces between separate words in the name of a custom field? I thought this was not allowed. Does it work if you put dashes between the words of the name of the custom field?


Prrrrrrrr

Offline

#5 2010-09-07 12:14:14

shadden
New Member
Registered: 2010-07-27
Posts: 8

Re: Include all images in category instead of entering Image IDs

No, I tried that too.

Offline

#6 2010-09-07 12:16:55

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Include all images in category instead of entering Image IDs

Hello Again,

If you are using the form ‘gallery’ unaltered it probably won’t work. Look at Bloke’s excellent help section in the smd_gallery plugin to help you create a form that will work for you.

Offline

#7 2010-09-07 12:19:18

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Include all images in category instead of entering Image IDs

Is it possible to leave spaces between separate words in the name of a custom field?

Yes

Does it work if you put dashes between the words of the name of the custom field?

Yes

as long as you use the same version of the name in the txp:if_custom field tag.

Last edited by joebaich (2010-09-07 12:22:10)

Offline

#8 2010-09-07 12:54:53

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Include all images in category instead of entering Image IDs

I had forgotten, until now, that Jonathan had written an excellent TXPTip called Galleriffic image gallery that details a different approach with the same end in mind. I’m sure that you could adapt that easily to include calling the image category name from a custom field which simplifies the matter of having multiple articles with galleries.

Last edited by joebaich (2010-09-07 12:59:16)

Offline

#9 2010-09-09 12:46:55

shadden
New Member
Registered: 2010-07-27
Posts: 8

Re: Include all images in category instead of entering Image IDs

Yes, that TXPTip was what I used to implement the gallery in the first place. What I don’t quite understand is how to alter it to call the category name based on the category name entered in the custom ‘Image Category Name’ field in any article. Any suggestions?

Offline

#10 2010-09-09 13:01:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: Include all images in category instead of entering Image IDs

shadden

It should work fine as you have it. Hmmm. Couple of random ideas to work through:

  1. specify the custom field name in all lower case inside smd_gallery’s category attribute
  2. remove limit="1" from the smd_gallery tag. Do you really only want to show one image in the gallery from the given category?

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2010-09-09 15:24:40

shadden
New Member
Registered: 2010-07-27
Posts: 8

Re: Include all images in category instead of entering Image IDs

Thanks Bloke. I’m a very new textpattern user and I’m not entirely used to the code yet…

I’ve tried several different attempts to get it to work and I’m sure that it’s a very small error somewhere in my code, but I can’t work it out.

joebaich mentioned that I must have the ‘gallery’ form incorrectly written. based on the code I have in my page template, adjusted to match your ideas above:

<txp:if_custom_field name="Gallery Image Category Name"> <div id="thumbs" class="navigation"> <txp:smd_gallery category="?gallery image category name" form="gallery" sort="Posted asc" /> </div> </txp:if_custom_field>

how would you write the gallery form to pull the images from the image category specified in the custom field? all i need is the image itself and the caption.

Offline

#12 2010-09-09 16:56:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: Include all images in category instead of entering Image IDs

shadden wrote:

Thanks Bloke. I’m a very new textpattern user and I’m not entirely used to the code yet…

If you’re new to TXP then smd_gallery probably isn’t helping as it’s a non-standard way of doing things :-\

First things first: where is your smd_gallery tag? Is it in a Form or Page template or directly in the article? I think the best place for it — considering what you want to achieve — is in an article Form (either _ default_ or whatever one you have nominated in your article tag). If it’s directly inside your Page template you need to make sure it’s contained in a <txp:article> (or <txp:article_custom>) tag because otherwise there are no custom fields to read! (it requires article context to do what you are trying to do)

Secondly, your gallery form will probably need to look something like this:

<txp:image id="{id}" /><span class="caption">{caption}</span>

All you’re saying there is that, for each image in your nominated category (all of which the smd_gallery tag grabs for you) you’d like to see the image with the given ID, and its caption inside a span.

If you’re not likely to repeat the code anywhere else then you can achieve the same effect with smd_gallery’s container instead of a Form. Here’s an equivalent to what you posted:

<txp:if_custom_field name="Gallery Image Category Name">
   <txp:smd_gallery wraptag="div" html_id="thumbs" class="navigation" category="?gallery image category name" sort="Posted asc">
      <txp:image id="{id}" /><span class="caption">{caption}</span>
   </txp:smd_gallery>
</txp:if_custom_field>

Does that help get you any further?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB