Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-08-01 15:03:22

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

[SOLVED] image gallery & article custom

Can I have the cake and eat it too?

Is there a way to have a list of images appear in image id order and have them linked to the articles they belong?

At the moment this page is generated by calling the images in the articles’ custom_fields. The problem is that what appear to be the last 2 publications are actually the 1st and 3rd. I can understand that the list is generated using the article_custom order (the last 2 belonging to the first article) but is there another way with which they could appear chronologically and link to their respective articles?

the code:

<txp:article_custom section="events, participations, about" limit="999">
<txp:smd_gallery id="?pubs_by_others" escape="">
<txp:permlink><img src="<txp:site_url />images/{id}.jpg" width="230" height="{height}" title="{alt}" alt="{alt}" class="grid_6" /></txp:permlink>
<div class="grid_17 prefix_1">{caption}</div>
</txp:smd_gallery>
</txp:article_custom>

> Edited to add: would a variable and rah_repeat do the job?
> changed the title to make it more relevant to the thread as it is developing.

Last edited by colak (2012-08-06 06:58:49)


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#2 2012-08-04 06:36:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

Re: [SOLVED] image gallery & article custom

Over 100 views and no suggestions?


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#3 2012-08-04 12:33:14

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: [SOLVED] image gallery & article custom

I’m not sure I totally get what’s that you’re trying to achive.
How is the “a way to have list of images appear in image id order” request connected to the “but is there another way with which they could appear chronologically and link to their respective articles” request?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2012-08-04 20:05:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

Re: [SOLVED] image gallery & article custom

Hi Julian,

Thanks for the response. Let me see if I can put it more clearly.

At the moment the entries of that page are listed according to article id but I would like them to appear in image id order.the catch is that I would like the images to be linked to articles.

The code posted above links the images to their respective articles but it also sorts them according to the articles’ ‘posted’ time stamp.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#5 2012-08-04 20:22:08

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: [SOLVED] image gallery & article custom

By “in image id order” you mean, in the (also chronological) order they are displayed in the Content -> Images tab?

Sounds like a task for smd_gallery & smd_query. With smd_gallery you get the list of images ids in (chronological?) order. Then, you loop over that list, and use smd_query to fetch each article, one by one. For that, you use smd_query to create a query which “asks” something like: “bring me the article which has, in the article_image field, this image id associated”.

Does it make sense?

You could even try if you can use article_custom instead of smd_query. As you can fetch/filter articles by a customfield value (customfieldname="value"), you could try what happens if you do <txp:smd_gallery ...><txp:article_custom article_image="{id}" /></txp:smd_gallery>.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2012-08-05 06:24:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

Re: [SOLVED] image gallery & article custom

Sounds like a task for smd_gallery & smd_query. With smd_gallery you get the list of images ids in (chronological?) order.

As I’m wrapping article_custom on smd_gallery, the chronological order i get is that of articles and not that of images as some articles have more than one image.

Then, you loop over that list, and use smd_query to fetch each article, one by one. For that, you use smd_query to create a query which “asks” something like: “bring me the article which has, in the article_image field, this image id associated”.

yes! except I’m using custom_fields. I will try this as it might work! Thanks soo much for your input.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#7 2012-08-05 08:07:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

Re: [SOLVED] image gallery & article custom

I’m now wondering if I can do it without any plugins…

This does not work but I think that I might be in the right track…

<txp:variable name="otherpubs" 
	value='<txp:article_custom section="events, participations, about" limit="999" break=",">
		<txp:if_custom_field name="pubs_by_others">
		<txp:custom_field name="pubs_by_others" />
		</txp:if_custom_field>
		</txp:article_custom>' />
<txp:if_variable name="otherpubs">
<txp:images id='<txp:variable name="otherpubs" />' sort="id desc" limit="999">
<div class="line">
<txp:article_custom limit="1"> <txp:hide>This does not work as it understandably returns the same article url for all images</txp:hide>
<txp:permlink>
<img src="<txp:site_url />images/<txp:image_info type="id" /><txp:image_info type="ext" />" 
			alt="<txp:image_info type="alt" />" 
			title="<txp:image_info type="alt" />" 
			width="<txp:image_info type="w" />" 
			height="<txp:image_info type="h" />" class="grid_6" />
</txp:permlink>
</txp:article_custom>
<div class="grid_17 prefix_1"><txp:image_info type="caption" escape="" /></div>
<div class="clear">&nbsp;</div>
</div>
</txp:images>
</txp:if_variable>

Last edited by colak (2012-08-05 10:03:36)


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#8 2012-08-05 17:09:50

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: [SOLVED] image gallery & article custom

What if you change this:

<txp:article_custom limit="1">

To this:

<txp:article_custom pubs_by_others='<txp:image_info type="id" />'>

Could that work?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#9 2012-08-05 17:42:23

Gocom
Developer
Registered: 2006-07-14
Posts: 4,476
Website

Re: [SOLVED] image gallery & article custom

maniqui wrote:

Could that work?

That will only work if the field contains a one, single image ID. If it contains comma-separated list of images, it will not find the corresponding article.

If that is the case and the field does contain just a one image ID, then you could just merely sort by the custom field. No other magic would be required in that case, it would give you the ID order. E.g.

<txp:article_custom pubs_by_others="_%" sort="custom_1 desc" limit="9999">
	<!--
		I'm in ID order (if there is just an image per article).
	-->
</txp:article_custom>

Where in the custom_1 is the custom field’s field name / associative ID. The pubs_by_others="_%" makes sure that custom field isn’t empty. The _ and the % are both wildcards. A _ matches exactly one character, and a % zero or more characters.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#10 2012-08-06 05:48:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,973
Website

Re: [SOLVED] image gallery & article custom

@Julián

No:(
it works like Jukka described meaning that it does not work.

@ Jukka

we have from 0-3 image ids/page currently


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

Board footer

Powered by FluxBB