Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-04-29 12:16:53

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

how to stop txp:images from outputting every image in the database

hello forum,

im bothering around with <txp:images />: according to the docs in the case of absence of filtering attributes it outputs nothing if the article_image field is empty. in fact, it behaves the other way round: if the field is empty, it outputs all images in the database. if values are entered, it restricts its output to this values. i found this discussion but still wonder what the current status quo is? do i make a mistake or are the docs not up-to-date?

thanks for clarifying

Offline

#2 2011-04-29 12:33:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: how to stop txp:images from outputting every image in the database

If you want to prevent anything from being output when there is (are) no article image(s) assigned, wrap your existing txp:images code in txp:if_article_image.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2011-04-29 14:11:23

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: how to stop txp:images from outputting every image in the database

Uh, Mr. Bloke, taghandlers.php, starting line 2924:

		if (!$where && $filters)
		{
			return ''; // If nothing matches, output nothing
		}

		if (!$where)
		{
			$where[] = "1=1"; // If nothing matches, start with all images
		}

Shouldn’t that just be:

		if (!$where)
		{
			return ''; // If nothing matches, output nothing
		}

Code is topiary

Offline

#4 2011-04-29 16:47:05

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

Re: how to stop txp:images from outputting every image in the database

jsoo wrote:

Uh, Mr. Bloke

That’s how I wanted it to behave (and I believe it did that in an original SVN cut) but I was overruled because the behaviour differed from that of file_download_list and link_list. Consistency (albeit bizarre and, imho, should have been changed across the board) was decidede to trump sanity!

The docs refer to the original behaviour so they should probably be changed.


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

#5 2011-04-29 19:23:03

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to stop txp:images from outputting every image in the database

@jakob: thanks. you once again saved my day.

@ the pros: i understand from your conversation that my impression is right, that the tag is not behaving like described in the docs. sure, it would be good to have it updated – at least for newbies like me :-)

edit: it would be good to have the docs – not the tag – updated.

Last edited by totoff (2011-04-29 19:23:47)

Offline

#6 2011-04-29 19:48:09

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: how to stop txp:images from outputting every image in the database

Docs updated. Ack, what awkward behavior to describe. @totoff: thanks for bringing this up.


Code is topiary

Offline

Board footer

Powered by FluxBB