Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-06 21:02:45

wchung
Member
Registered: 2009-04-23
Posts: 29

Excluding Articles without Images from List

On my homepage I am showing the thumbnail from a random article within a section. However, there are a number of articles that do not have an image assigned to it. So at times the image space turns up blank.

How do I exclude from the random sort the articles that do not have an image and thumbnail?

Thanks.

Offline

#2 2009-11-06 21:08:10

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

Re: Excluding Articles without Images from List

It’s a shame this trick doesn’t help.


My Plugins

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

Offline

#3 2009-11-06 21:16:58

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

Re: Excluding Articles without Images from List

Try this plugin: soo_article_filter


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2009-11-06 22:35:35

wchung
Member
Registered: 2009-04-23
Posts: 29

Re: Excluding Articles without Images from List

Thanks for suggesting soo_article_filter.

So I tried the following on the page template where the image is to appear:

<txp:soo_article_filter upm_article_image=“1”>

<txp:article_custom limit=“1” section=pros sort=“rand()” form=“Image” />

</txp:soo_article_filter>

Then for my form called Image I entered:

<txp:soo_article_filter upm_article_image=“1”>

<txp:permlink>

<txp:upm_article_image type=thumbnail limit=1 />

</txp:permlink>

</txp:soo_article_filter>

***

But I still get an occasional blank. I had also tried it with the soo_article_filter tag on only the page template, but the results were the same.

Any suggestions?

Thanks!

Offline

#5 2009-11-06 22:51:07

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excluding Articles without Images from List

Any suggestions?

a) 1 soo_article_filter should be sufficient: the one around the article_custom tag.
b) Change <txp:soo_article_filter upm_article_image="1"> to <txp:soo_article_filter article_image="1">


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2009-11-06 23:06:13

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

Re: Excluding Articles without Images from List

Uli is correct on both points.


Code is topiary

Offline

#7 2009-11-06 23:12:06

wchung
Member
Registered: 2009-04-23
Posts: 29

Re: Excluding Articles without Images from List

Thanks, but when I made the change I am still getting a blank every few. It occurred to me that it may be because some of the images may not have thumbnails attached to them. Is there some way to expressly exclude the articles without thumbnails as opposed to images? That may solve the problem.

Also, the reason I used upm_article_image is because I am using the upm_article_image plugin.

Thanks again to both of you!

Offline

#8 2009-11-07 03:18:11

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excluding Articles without Images from List

wchung wrote:

it may be because some of the images may not have thumbnails attached to them.

I don’t think so. I rather quickly discovered two faults in your code, and looking a second time there are still more than just 2 apostrophes missing … Try writing proper code, it helps most of the time. If not … post again with your code. BTW, even copying forum code that’s not wrapped in pre tags can cause a page to fall apart, it’s important to have straight quotes, not curly ones.

Another possibility: Faulty code inside some articles.

EDIT: Replace sort="rand()" by e.g. sort="posted desc" so you can see exactly which articles cause blank pages.

Last edited by uli (2009-11-07 03:39:15)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB