Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-08-06 15:33:09

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [SOLVED] image gallery & article custom

Well, I’d try it, at least, to see if you could get it working. Then, if the code is too resource-intensive, you could wrap it with aks_cache, doing a clever usage of its attributes, like the TTL value, and maybe even the “no-reset” attribute, if you think this page won’t change that often and will benefit of a longer caching time than other contents. In other words, you could keep this page cached, even if you globally configure aks_cache to reset when website updates.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2012-08-08 14:28:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] image gallery & article custom

apologies for my silence
I am again having some time to experiment…

<txp:article_custom section="events, participations, about" limit="999">
<txp:smd_gallery limit="999">
  <txp:smd_query column="*" table="textpattern" break=""
                          where='
                              custom_6 LIKE "{id}"
                              OR custom_6 LIKE "%,{id},%"
                              OR custom_6 LIKE "%,{id}"
                              OR custom_6 LIKE "{id},%"
                            AND status=4'
                        >
<div class="line">
<txp:permlink><txp:image id="{id}" alt="{alt}" title="{alt}" class="grid_6" /></txp:permlink>
<div class="grid_17 prefix_1">{caption}</div>
<div class="clear">&nbsp;</div></div>
  </txp:smd_query>
</txp:smd_gallery>
</txp:article_custom>

The results and issues

  • the images appear in the right order and are linked to the right articles
  • the set of images appears 22 times
  • html in captions is escaped so it is all viewable in the front end

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#15 2012-08-08 14:39:52

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [SOLVED] image gallery & article custom

You are fetching articles more than once: in the outer article_custom loop and in the smd_query (which is call once for each loop in smd_gallery).
So, try removing the wrapping article_custom, it shouldn’t be there.

You could narrow the query by adding

where'
    section="events" 
   OR section="participations"
   OR section="about"
   ...

Re: html in captions: in smd_gallery, you could try setting escape="alt" (as plugin defaults to escape="alt, title, caption").


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#16 2012-08-08 15:02:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] image gallery & article custom

maniqui wrote:

You could narrow the query by adding…

Hi Julián,

here i am showing my ignorance:) Is this what you mean?

<txp:smd_gallery limit="999" escape="">
  <txp:smd_query column="*" table="textpattern" break=""
                          where='
                              custom_6 LIKE "{id}"
                              OR custom_6 LIKE "%,{id},%"
                              OR custom_6 LIKE "%,{id}"
                              OR custom_6 LIKE "{id},%"
                          where'
                              section="events" 
                              OR section="participations"
                              OR section="about"
                            AND status=4'
                        >
<div class="line">
<txp:permlink><txp:image id="{id}" alt="{alt}" title="{alt}" class="grid_6" /></txp:permlink>
<div class="grid_17 prefix_1">{caption}</div>
<div class="clear">&nbsp;</div></div>
  </txp:smd_query>
</txp:smd_gallery>

Last edited by colak (2012-08-08 15:05:49)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#17 2012-08-08 15:14:58

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [SOLVED] image gallery & article custom

Yiannis, sorry, me being lazy.
This is what I meant:

<txp:smd_gallery limit="999" escape="">
  <txp:smd_query column="*" table="textpattern" break=""
                          where='
                              section="events" 
                              OR section="participations"
                              OR section="about"
                              AND (
                                custom_6 LIKE "{id}"
                                OR custom_6 LIKE "%,{id},%"
                                OR custom_6 LIKE "%,{id}"
                                OR custom_6 LIKE "{id},%"
                            )
                            AND status=4'
                        >
<div class="line">
<txp:permlink><txp:image id="{id}" alt="{alt}" title="{alt}" class="grid_6" /></txp:permlink>
<div class="grid_17 prefix_1">{caption}</div>
<div class="clear">&nbsp;</div></div>
  </txp:smd_query>
</txp:smd_gallery>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#18 2012-08-08 15:54:34

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] image gallery & article custom

This returns a lot of <div class="line">...</div> and some places where the images do not display but their captions do. Again there are multiple instances of the sets.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#19 2012-08-09 15:56:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] image gallery & article custom

i solved it. The solution is not as automated as I would have liked but it works. It uses the image name field as part of the url. Here is the code should anybody wants to use it and here it is in action

<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:hide>collect all image ids from the custom_fields into a variable</txp:hide>
<txp:if_variable name="otherpubs">
<txp:images id='<txp:variable name="otherpubs" />' sort="id desc" limit="999"><txp:hide>the variable is used to collate the image ids and sort them</txp:hide>
<txp:if_different><txp:hide>omit any duplicate ids</txp:hide>
<div class="line">
<a href="<txp:site_url /><txp:image_info type="name" />"><txp:hide>link to the required pages using the image name field</txp:hide>
	<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"  
	id="a<txp:image_info type="id" /> "/></a>
<div class="grid_17 prefix_1"><txp:image_info type="caption" escape="" /></div><txp:hide>image caption with html content</txp:hide>
<div class="clear">&nbsp;</div>
</div>
</txp:if_different>
</txp:images>
</txp:if_variable>

> Edit: for existing sites it might be easier to use <txp:images id='<txp:variable name="otherpubs" />' sort="alt desc" limit="999"> instead of <txp:images id='<txp:variable name="otherpubs" />' sort="id desc" limit="999">

Last edited by colak (2012-08-10 04:31:50)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB