Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-24 09:54:49

hellosmithy
New Member
Registered: 2007-07-24
Posts: 9

display all images from a category in an xml file

Hi everyone,

I’m trying to display all my images from category ‘image-gallery’ into an xml file for a flash file to read and generate an image gallery from. So far I’ve not found any info on this, and it seems the image tags such as txp:image_index can’t output what I want as it can’t be told what to output by a form. Does anyone have any ideas?
Ideally I’d like to output something like this:

<gallery>
	<gallery-item>
		<image url="url of image" />
		<thumb url="url of thumbnail" />
		<caption>image caption or alt text here</caption>
	</gallery-item>
</gallery>

Many thanks,

Ben

Last edited by hellosmithy (2008-10-24 16:54:05)

Offline

#2 2008-10-24 10:11:44

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

Re: display all images from a category in an xml file

hellosmithy wrote:

I’m trying to display all my images from category ‘image-gallery’ into an xml file for a flash file to read and generate an image gallery from.

Hi, a couple of plugins that might help you achieve this:

  • mg_setheader : Put this on a Page template to set an XML mime type
  • smd_gallery : Generate the gallery itself. You can put the call to this plugin directly on your page so it will insert the relevant tags for each image

For example, on a Page template (untested) :

<txp:mg_setheader /><?xml version="1.0" encoding="UTF-8"?> 
<gallery>
<txp:smd_gallery category="image-gallery">
  <gallery-item>
    <image url="{url}" />
    <thumb url="{thumburl}" />
    <caption>{title}</caption>
  </gallery-item>
</txp:smd_gallery>
</gallery>

Does that get you going? It’ll create what I call a “fake” xml file under your chosen section, but if you point your flash file at the relevant section it should read it and interpret it as a proper XML file (he says, hoping…)

Last edited by Bloke (2008-10-24 10:15:22)


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

#3 2008-10-24 14:28:50

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

Re: display all images from a category in an xml file

This looks very interesting. I had been looking for a way to automate the xml creation so that I could update Monoslideshow from within Textpattern. A typical configuration file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<slideshow>
	<preferences
		backgroundColor = "000000"
		showLoadingIcon = "false"
		showAlbumsButton = "false"
		showThumbnailsButton = "false"
		showControls = "false"
		showImageInfo = "never"
		imageTransitionTime = "2"
		imagePause = "10"
		kenBurnsMode = "random"
		kenBurnsTime = "7"
		kenBurnsVariationPercent = "40"
		markFile = ""
	/>
	<album title="Example album" description="Example description" imagePath="album/images">
		<img src="img-01.jpg"/>
		<img src="img-02.jpg"/>
		<img src="img-03.jpg"/>
	</album>
</slideshow>

I suppose I could use the article tilte and excerpt fields for title and description respectively. The imagePath would then be txp’s default image directory?!

Offline

#4 2008-10-24 16:59:58

hellosmithy
New Member
Registered: 2007-07-24
Posts: 9

Re: display all images from a category in an xml file

Bloke wrote:

Does that get you going? It’ll create what I call a “fake” xml file under your chosen section, but if you point your flash file at the relevant section it should read it and interpret it as a proper XML file (he says, hoping…)

Hi Bloke,
that worked a treat – thanks very much!

Last edited by hellosmithy (2008-10-24 17:03:40)

Offline

#5 2008-10-25 04:46:18

hellosmithy
New Member
Registered: 2007-07-24
Posts: 9

Re: display all images from a category in an xml file

Bloke,
I’ve had a play round with your plugin – it’s very useful and I’m sure I can use this on a lot of projects thanks very much!
I have one question but I’m not sure how feasible it is – I’m using a multi-lingual plugin called MLP which creates multilingual entries across all my articles and images.

So my current image files have 4 captions and 4 alt entries for 4 different languages. For most stuff MLP will then deliver the correct language for article text or image alt text etc based on the current URL eg. mysite.com/en/section/ for English or mysite.com/fr/section/ for French. However with your gallery plugin it always pushes through the first set of English alt/caption tags. Is this something that can be worked around?

Many thanks,

Ben

Last edited by hellosmithy (2008-10-25 04:46:59)

Offline

#6 2008-10-25 05:17:28

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: display all images from a category in an xml file

hellosmithy wrote:

So my current image files have 4 captions and 4 alt entries for 4 different languages. For most stuff MLP will then deliver the correct language for article text or image alt text etc based on the current URL eg. mysite.com/en/section/ for English or mysite.com/fr/section/ for French. However with your gallery plugin it always pushes through the first set of English alt/caption tags. Is this something that can be worked around?

Many thanks,

Ben

Shouldn’t this question really be in the plugin support article? I might have seen it discussed there.

Last edited by MattD (2008-10-25 05:25:27)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#7 2008-10-25 08:12:50

hellosmithy
New Member
Registered: 2007-07-24
Posts: 9

Re: display all images from a category in an xml file

Sorry you’re right wrong section -
well I’m now using smd_gallery for a gallery that does not require MLP, and I’ve managed to get the output I wanted for the MLP section with an ugly hack of upm_image working with wet_for_each_image for anyone interested.

Offline

Board footer

Powered by FluxBB