Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2010-01-08 15:46:54

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Image Gallery / Content Slider

Bloke wrote:

CodeWalker wrote:

Unable to include required plugin “smd_lib”

Try installing and activating smd_lib ; a required component of smd_gallery :-)

of course! silly me.

Offline

#17 2010-01-08 16:12:59

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Image Gallery / Content Slider

Bloke wrote:

EDIT: Els, do you think the general flow I proposed above makes sense? Any better ideas? Any thoughts on how to put HTML into the mix as well?

I admit I’m not sure what the exact outcome should be, but if the output should only be either one of image, video or html/text, the simplest way in my opinion is to use articles that have either an article image assigned, or a custom field for the video, or the excerpt for the html. Then use conditionals (if_article_image, if_custom_field, if_excerpt, maybe even if_variable) to determine which one is needed.

CodeWalker’s setup may well be far more complicated than this; still the right mix of variable and if_variable tags can achieve an awful lot… ;)

Offline

#18 2010-01-08 16:32:06

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Image Gallery / Content Slider

actually you have just made me realise something. There may be a really rare occassion when i only have one image or one excerpt or one video to display. in the this case, the whole slider setup would be totally wasted.

How, if there is a way, do i get it to check. Can i somehow count the number of images in category and if theres more than one, use form_slider, if theres just one image in the category use form_single_image instead?

im not huge programmer, aside from a very basic grasp of PHP. if theres a better way, then please share :)

so heres wot needs to happen

check for more than one image in a category

-> if so, list them in the slider with form_image_cat_list ->then check for videos and list those aswell with form_video_cat_list
-> if there are no images, check for a video in the downloads catagory and list those in the slider if theres more than one by outputting form_video_cat_list
-> if only one video exists, output form_single_video.

-> if there are no videos or images -> output form_excerpt_only

Does this make sense? im sure its just a bunch of if else statements but i rly dont know how.

Many thanks.

Last edited by CodeWalker (2010-01-08 16:45:47)

Offline

#19 2010-01-08 16:57:59

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Image Gallery / Content Slider

Where do you fetch the (images and files) category name? Is it the same category as the article is in? Is it in a custom field?

Last edited by els (2010-01-08 16:58:17)

Offline

#20 2010-01-08 17:02:18

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Image Gallery / Content Slider

ok, Bloke suggested setting the image and videos (via the downloadlinks) catagories to same name so that way i can set that in a custom field to populate the slider with both video and images with a single custom feild.

Make sense?

Offline

#21 2010-01-08 17:08:51

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Image Gallery / Content Slider

CodeWalker wrote:

Make sense?

Yes :) To figure out how to check for the number of images in a category, can you tell me which plugin you are using now, wet_for_each_image or smd_gallery? I haven’t used smd_gallery myself, so you’d have to tell me what the tag you are using to display the images looks like.

Offline

#22 2010-01-08 17:09:13

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Image Gallery / Content Slider

would it be simpler to do it the other way round, instead of checking the number of image? as in, use a single image or video by defualt and if theres a value in the custom field then go ahead and use the slider instead?

that seams more elegant to me.

so if custom feild has a value, output slider_form using custom value to pull in images and video from a named catagory, else output form_single_image.

my previous idea might be goood try aswell tho, just so i can see how both work in practice.

im using wet_for_each_image

Last edited by CodeWalker (2010-01-08 17:11:00)

Offline

#23 2010-01-08 17:29:22

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Image Gallery / Content Slider

Before I read your last post (so maybe you won’t need this after all), I came up with something like the example below. It’s just a raw idea, you might need to tweak it a little, change the order, or whatever, but it gives you an idea of how to check for content. I have to go out now, so if you have any questions about it you’ll have to figure it out yourself or wait for someone else to explain it ;)

<txp:variable name="any_images" value='<txp:wet_for_each_image category=''<txp:custom_field name="nameofcustomfield" />'' />' limit="1" />
<txp:variable name="mt1_images" value='<txp:wet_for_each_image category=''<txp:custom_field name="nameofcustomfield" />'' />' offset="1" limit="1" />
<txp:variable name="any_videos" value='<txp:file_download_list category=''<txp:custom_field name="nameofcustomfield" />'' limit="1" />
<txp:variable name="mt1_videos" value='<txp:file_download_list category=''<txp:custom_field name="nameofcustomfield" />'' offset="1" limit="1" />

<txp:if_variable name="any_images" value="">
	//no images, check for videos
	<txp:if_variable name="any_videos" value="">
		// no videos, check for excerpt
		<txp:if_excerpt>
			// call form_excerpt_only
		</txp:if_excerpt>
	<txp:else />
		<txp:if_variable name="mt1_videos" value="">
			// only one video
			// call form_single_video
		<txp:else />
			// more than one video
			// call form_video_cat_list
		</txp:if_variable>
	</txp:if_variable>
<txp:else />
	<txp:if_variable name="mt1_images" value="">
		// only one image
		// call form_single_image
	<txp:else />
		// more than one image
		// call form_slider
	</txp:if_variable>
</txp:if_variable>

Last edited by els (2010-01-08 17:30:14)

Offline

#24 2010-01-08 17:53:48

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: Image Gallery / Content Slider

thanks Els, that looks helpful. Hope you have fun out.

ill give it a go and see how far i get.

CHeers :)

Offline

#25 2010-10-27 20:07:16

kuro
Member
From: Mexico City | Mérida, Yucatán
Registered: 2005-08-26
Posts: 74
Website

Re: Image Gallery / Content Slider

Els:
If i want to do something like this

Do have i to create this?

1.- image_layout form, video_layout form (as Bloke write for us)

2.-
bq. <txp:if_custom_field name=“folio_content”>
<div id=“loopedSlider”> <div class=“container”> <ul class=“slides”> <txp:upm_image category=’<txp:custom_field name=“folio_content” />’ form=“image_layout” /> <txp:file_download_list catgeory=’<txp:custom_field name=“folio_content” />’ form=“video_layout” /> </ul> </div>
</div>
</txp:if_custom_field>

and this:

3.-
bq. <txp:variable name=“any_images” value=’<txp:wet_for_each_image category=’‘<txp:custom_field name=“nameofcustomfield” />’‘ />’ limit=“1” />
<txp:variable name=“mt1_images” value=’<txp:wet_for_each_image category=’‘<txp:custom_field name=“nameofcustomfield” />’‘ />’ offset=“1” limit=“1” />
<txp:variable name=“any_videos” value=’<txp:file_download_list category=’‘<txp:custom_field name=“nameofcustomfield” />’‘ limit=“1” />
<txp:variable name=“mt1_videos” value=’<txp:file_download_list category=’‘<txp:custom_field name=“nameofcustomfield” />’‘ offset=“1” limit=“1” />
<txp:if_variable name=“any_images” value=”“> //no images, check for videos <txp:if_variable name=“any_videos” value=”“> // no videos, check for excerpt <txp:if_excerpt> // call form_excerpt_only </txp:if_excerpt> <txp:else /> <txp:if_variable name=“mt1_videos” value=”“> // only one video // call form_single_video <txp:else /> // more than one video // call form_video_cat_list </txp:if_variable> </txp:if_variable>
<txp:else /> <txp:if_variable name=“mt1_images” value=”“> // only one image // call form_single_image <txp:else /> // more than one image // call form_slider </txp:if_variable>
</txp:if_variable>

Ps. what it means mt1_videos?
Thanks

Offline

#26 2010-10-27 21:55:56

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Image Gallery / Content Slider

kuro wrote:

If i want to do something like this

Do have i to create this?

Well, the easiest way would be to get the headlines theme and use the ready-made code ;)
But if all you want to display is the article and its article image, then no, you won’t need most of the stuff posted in this thread. What the original poster wanted to do was to mix different content types, and check if there exists more than one instance of each type.
In this case, it looks like you only need an article or article_custom tag inside the <ul class="slides">...</ul>.

Ps. what it means mt1_videos?

Hehe, that’s just my idea of using ‘meaningful’ variable names: more than one ;)

Offline

Board footer

Powered by FluxBB