Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Gallerific with Current TXP image tags -- how to implement
Note that you can only assign a single image to each article
While txp:article_image may only be able to accept one ID, you can get around it with other tags or a plugin. A typical situation is to enter a comma-separated list of image ID numbers and have your page template iterate over them to construct a gallery. There are a myriad of different ways, one of which using txp:images Marc/maruchan outlined above.
TXP Builders – finely-crafted code, design and txp
Offline
#17 2011-08-17 18:33:42
- WebmistressM
- Member
- Registered: 2011-08-12
- Posts: 61
Re: Gallerific with Current TXP image tags -- how to implement
maruchan wrote:
<txp:if_article_id id="3"><!-- if we're NOT on the section landing page, and are viewing an article with ID of 3 (for example..could be any ID) -->
<txp:article>
<h1><txp:title /></h1>
<txp:if_article_image><!-- make sure images are assigned to article -->
<txp:images><!-- show all the images assigned to this article, NOTE you could also loop thru all images in this category, and forego the use of article_images -->
<img src="<txp:image_url />" alt="<txp:image_info type="alt" />" />
</txp:images>
</txp:if_article_image>
</txp:article>
</txp:if_article_id><!-- finished with content for article of ID 3 -->
<!-- you can put the other two article_id tests here; each article can have its own layout if needed -->
</txp:if_section>
<txp:if_section name="graphic-arts">
<!-- same pattern as above -->
</txp:if_section>
Im curious if this if_article type tag can help with the 1 image vs multiple if/then scenario. Basically, something that will “hide” the carousel of thumbs if the article only has one image assigned to it from the images uploaded.
Offline
#18 2011-08-17 19:09:58
- WebmistressM
- Member
- Registered: 2011-08-12
- Posts: 61
Re: Gallerific with Current TXP image tags -- how to implement
Found this hide code for an image gallery, sourced from here:
http://textpattern.net/wiki/index.php?title=Creating_a_Photoblog
<txp:if_section name="">
<txp:hide>
we're on the homepage, so display one image
</txp:hide>
<txp:article form="image" limit="1"/>
</txp:if_section>
Think I could adapt it using some sort of “less than”/“Greater than” or is this simpler than that?
Offline
Re: Gallerific with Current TXP image tags -- how to implement
I don’t think your example will help and the txp:if_article_image tag is also of limited help as it will only test if there is “something” in the field but not what it is.
What you could do is use txp:images and and txp:variable to test if there is more than one image and output your show-image / show-image-gallery code appropriately. An example (untested):
<txp:if_article_image>
<!-- the article_image field contains something -->
<txp:variable name="is_image_sequence" value='<txp:images limit="1" offset="1" break="" />' />
<!-- save the second image in a variable -->
<txp:if_variable name="is_image_sequence" value="">
<!-- variable is empty: single image code -->
<txp:else />
<!-- variable not empty: image gallery code -->
</txp:if_variable>
</txp:if_article_image>
What this does is use the offset and limit attributes to retrieve the second image in the list. If there is one, the variable will contain something, if there is no second image, the variable should be empty. You then use if_variable to display either a single image or multiple images. BTW: this all needs to be in an individual article context so that txp:images automatically looks in the article_image field.
TXP Builders – finely-crafted code, design and txp
Offline
#20 2011-08-17 22:25:12
- WebmistressM
- Member
- Registered: 2011-08-12
- Posts: 61
Re: Gallerific with Current TXP image tags -- how to implement
<txp:if_article_image>
<txp:variable name=“is_image_sequence” value=’<txp:images limit=“1” offset=“1” break=”“ />’ />
<!— save the second image in a variable —>
<txp:if_variable name=“is_image_sequence” value=”“>
<!— provide a simple image thumbnail using the permalink for href —>
<txp:permlink><txp:article_image thumbnail=“1” /></txp:permlink>
<txp:else />
<txp:images>
<a href=”<txp:image_url />”><txp:thumbnail /></a>
</txp:images>
</txp:if_variable>
</txp:if_article_image>
***
That is in my current form, having all article images show in thumbnail form, if the article has em.
Last edited by WebmistressM (2011-08-17 22:46:55)
Offline