Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#937 2015-04-30 14:42:58

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: smd_gallery: super-flexible gallery generator

I am probably being a bit slow today. Hopefully someone can help. I simply want the user to click on a thumbnail which will bring up a lightbox of that gallery/category of images. I also want the thumbnail to be the last in the set. Is this possible?

Last edited by miles (2015-04-30 14:43:25)

Offline

#938 2015-04-30 15:35:43

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

Re: smd_gallery: super-flexible gallery generator

miles wrote #290317:

click on a thumbnail which will bring up a lightbox of that gallery/category of images. I also want the thumbnail to be the last in the set.

Not sure this is the most elegant way to approach it, but I think it does what you want:

<txp:smd_gallery category='<txp:custom_field name="article_image" />'>
   <txp:variable name="thisImg">{counter}</txp:variable>
   <txp:variable name="imgTotal">{maximages}</txp:variable>
   <a rel="lightbox-{category}" href="{url}">
      <txp:if_variable name="thisImg" value='<txp:variable name="imgTotal" />'>
         <txp:thumbnail id="{id}" />
      </txp:if_variable>
   </a>
</txp:smd_gallery>

Notes:

  • Reads the category name from the article image field.
  • Assumes your lightbox script is already loaded on the page (in this case, the standard lightbox).
  • Since the thumbnail is the last one, your gallery starts from there, thus you need to ensure your navigation wraps at each end or visitors might get confused why they can’t use ‘next’ when they enter the gallery.
  • You can simplify the code if you have smd_if installed to replace the variable/if_variable stuff.

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

#939 2015-05-17 13:48:13

pierlu
Member
Registered: 2014-08-12
Posts: 153

Re: smd_gallery: super-flexible gallery generator

Vorrei fare in modo che sotto ad ogni articolo della sezione “dove dormire” abbia la sua gallery.
Usando plugin smd gallery ho scritto

<txp:if_custom_field name="galleria1"> 
<div class="fotosagra1">
<div class="gallerycascioinfesta">
<h1>Alcune foto </h1>
<txp:smd_gallery category="?agrturismo" form="galleryart"/>
</txp:smd_gallery> </div> </div>
</txp:if_custom_field>

Non Viene niente, cosa sbaglio?

la galleria che ho per ora si chiama “agriturismo-lafoce” e “agriturismo-labetulla”

EDITED: bc.. code added

Offline

#940 2015-05-17 14:31:59

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

Re: smd_gallery: super-flexible gallery generator

<txp:if_custom_field name="galleria1"> 
  <div class="fotosagra1">
    <div class="gallerycascioinfesta">
      <h1>Alcune foto</h1>
      <txp:smd_gallery category="?agrturismo" form="galleryart" />
    </div>
  </div>
</txp:if_custom_field>

It looks like you have an extra closing </txp:smd_gallery> in there which you don’t need.

If the above is in an article form or an if_individual_article section, it will output the code if you have something in the custom field “galleria1” and show the gallery of images in the image category agrturismo using the galleryart form. Otherwise, check your spelling is correct (is there perhaps an i is missing in the category agriturismo?).


TXP Builders – finely-crafted code, design and txp

Online

#941 2015-05-17 16:43:45

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_gallery: super-flexible gallery generator

I suppose that category="?agrturismo" is misspelled.

Offline

#942 2015-05-18 18:28:48

pierlu
Member
Registered: 2014-08-12
Posts: 153

Re: smd_gallery: super-flexible gallery generator

Ho scritto così <txp:if_custom_field name=“galleria1”>
<div class=“fotosagra1”>
<div class=“gallerycascioinfesta”>
<h1>Alcune foto </h1>
<txp:smd_gallery category=”?agriturismo” form=“galleryart” /> </div> </div>
</txp:if_custom_field>

ma non ho nessun risultato perchè?

Offline

#943 2015-05-18 18:34:26

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_gallery: super-flexible gallery generator

The category name is with or without a question mark? Or, what means that question mark?

Offline

#944 2015-05-18 19:17:49

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

Re: smd_gallery: super-flexible gallery generator

Good catch. I think you’re right (again). It should be category="agriturismo" without a ? mark.

As an aside: smd_gallery does use question marks to denote “what is in the ?field-name of the current article”, e.g. ?article_image. A question mark before ?agriturismo means “the category written in the custom field named agriturismo”.


TXP Builders – finely-crafted code, design and txp

Online

#945 2015-05-18 19:27:00

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_gallery: super-flexible gallery generator

jakob wrote #290885:

As an aside: smd_gallery does use question marks to denote “what is in the ?field-name of the current article”, e.g. ?article_image. A question mark before ?agriturismo means “the category written in the custom field named agriturismo”.

Thanks, I never used smd_gallery and I think it isn’t necessary today with the current tags, but that doesn’t matter here.

Offline

#946 2015-05-19 08:17:52

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

Re: smd_gallery: super-flexible gallery generator

GugUser wrote #290886:

I never used smd_gallery and I think it isn’t necessary today with the current tags

Thanks for helping sort out pierlu’s issue. Yes, the question marks are a little non-standard: they pre-date proper tags-in-attribute support. Nowadays, you can achieve the same thing — in the plugin or in core — albeit with a little more typing, e.g.:

<txp:images category='<txp:custom_field name="my-field-name" />' form="galleryart" />

When I did the core image tags, they were inspired by some of the more standard portions of smd_gallery, so you’re right that the plugin is only useful if you’re doing some really wacky stuff with counts, pagination, custom combos and so forth. Such things would be a lot more difficult with native tags.


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

#947 2015-05-19 12:54:33

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_gallery: super-flexible gallery generator

Hi Bloke. I appreciate your plugins very (at what position should be “very”? :-) ). My comment was not against this plugin, just I never needed it. Thanks for all you good und helpful work.

Last edited by GugUser (2015-05-19 12:55:36)

Offline

#948 2018-02-25 18:52:47

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: smd_gallery: super-flexible gallery generator

Hi,

I’m trying to either display a gallery of 4 images cycling or a static image if one has been associated with the current article. That part works.

However I also want to display only images from a sub-category if we’re on a category page. I named the sub-categories ‘headers-norway’, ‘headers-iceland’, ‘headers-india’ etc. relating to the article categories ‘norway’, ‘iceland’, ‘india’ hoping I could call them using something like this:

<txp:smd_gallery category='headers-"<txp:category />"' sublevel="1" limit="4" sort="random" wraptag="div" html_id="header-slideshow">
			<img src="{url}" alt="{alt}" width="960" height="400" />
	</txp:smd_gallery>

… in an attempt to merge the literal 'headers-' with the output of <txp:category /> but no output is generated.

I’d be very grateful for any help :)

I pasted the full code below.

<txp:if_individual_article>
	<txp:if_custom_field name="header-image">
		<div id="header-image">
			<txp:article>
				<txp:image id='<txp:custom_field name="header-image" />' />
			</txp:article>
		</div>
	<txp:else />
		<txp:smd_gallery category='header-slideshows' sublevel="all" limit="4" sort="random" wraptag="div" html_id="header-slideshow">
			<img src="{url}" alt="{alt}" width="960" height="400" />
		</txp:smd_gallery>
	</txp:if_custom_field>
<txp:else />
	<txp:if_category>
		<txp:smd_gallery category='headers-"<txp:category />"' sublevel="1" limit="4" sort="random" wraptag="div" html_id="header-slideshow">
			<img src="{url}" alt="{alt}" width="960" height="400" />
		</txp:smd_gallery>
	<txp:else />
		<txp:smd_gallery category='header-slideshows' sublevel="all" limit="4" sort="random" wraptag="div" html_id="header-slideshow">
			<img src="{url}" alt="{alt}" width="960" height="400" />
		</txp:smd_gallery>
	</txp:if_category>
</txp:if_individual_article>

Offline

Board footer

Powered by FluxBB