Textpattern Forum

You are not logged in. Register | Login | Help

#31 2010-12-09 21:46:02

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Output sticky articles first in an article list

I wish I would use the v.3 but as it has more power on images but for for now I’m using v.2…


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#32 2010-12-09 21:47:28

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Output sticky articles first in an article list

I’d really like to use your plugin but I’m trying to filter a very special case here and I’m concerned about memory usage….

Last edited by hablablow (2010-12-09 21:49:51)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#33 2010-12-09 21:48:35

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,380
Website

Re: Output sticky articles first in an article list

jsoo wrote:

For the first article, yes. Then it will evaluate the if_article_image block, which is capable of changing the value of the variable.

Oh yes, sorry, I missed the second txp:variable tag… now I understand your code, Jeff. But I don’t see how the article_custom tag in there could display the right article… I think you need to replace it with just the content of the form.


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#34 2010-12-09 21:50:46

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Output sticky articles first in an article list

I know Els but then I will miss the upm_article_image… The image will not appear….

Last edited by hablablow (2010-12-09 21:51:45)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#35 2010-12-09 21:54:52

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: Output sticky articles first in an article list

hablablow wrote:

I know Els but then I will miss the upm_article_image… The image will not appear….

Obvious question is: is this a upm_image issue then? What output do you get if the selected article has only one image assigned, and you use a regular article_image tag?


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#36 2010-12-10 00:28:06

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,380
Website

Re: Output sticky articles first in an article list

I think we might understand better why things don’t work for you if we knew the full code you are using…


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#37 2010-12-10 16:30:05

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Output sticky articles first in an article list

And it’s finally working with the solution provided by Jeff and the upm_article_image plugin

Like this:

<txp:if_article_list>
<!-- We are in an article list context -->
<!-- Step: 1 -->
<!-- Is there a sticky article in this list ?  -->
<!-- Build a variable that tries to output any found sticky article  -->
<txp:variable name="stickit"><txp:article status="sticky" limit="1">dummy text</txp:article></txp:variable>
	<txp:if_variable name="stickit" value="">
		<!-- There's no sticky article ! Just fire the first live article found -->
		<!-- Step: 2 -->
		<!-- Does the article have an image associated ? -->
		<txp:variable name="art_img" value="" /> <!-- Edit: need to initialize the variable -->
			<!-- Let's try over the next 5 articles to check if at least 1 has an image associated -->
			<txp:article limit="5">
					<txp:if_variable name="art_img" value="">
						<txp:if_article_image>
							<!-- If an article with an image is found display the article details -->
								<txp:title />
								<txp:body />
								<txp:upm_article_image form="image_details">
								<txp:variable name="art_img" value="1" />
						</txp:if_article_image>
					</txp:if_variable>
			</txp:article>
	<txp:else />
		<!-- We have a Sticky article, just display it -->
		<txp:article status="sticky" limit="1">
		<txp:title />
		<txp:body />
		</txp:article>
	</txp:if_variable>
</txp:if_article_list> 

Now for the fine folks jumping to the end of this thread the above will do this, in an article list context:

1- If there’s a Sticky article display it first.
2- If not, display a live article that has an image.
3- If no image associated with the article, skip to the next article that has an image.

Et voilà !

Thanks a lot: Julian, Jsoo, Els… Any details to add to the code above ? Comments ?

Well I guess code is like Lasagna, it tastes better the day after you cooked it…
Thank you very much folks for the fine cooking advices !

:)

Last edited by hablablow (2010-12-10 16:55:23)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#38 2010-12-10 16:50:21

jsoo
Developer
From: NC, USA
Registered: 2004-11-15
Posts: 1,730
Website

Re: Output sticky articles first in an article list

You’ll need an article status="sticky" limit="1" tag surrounding the title and body in your else block.


Txp tags not doing what you expect? Learn to use a tag trace. And the Tag Reference.

Offline

#39 2010-12-10 16:56:10

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Output sticky articles first in an article list

Corrected Jeff. Thanks again for your help, much appreciated !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#40 2010-12-11 01:57:28

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,178
Website

Re: Output sticky articles first in an article list

Gillaume, can you send this over to TXP Tips?


TXP Tips | @txptips | Me | @jonathanstubbs | Github

TXP Builders – finely-crafted code, design and txp @txpbuilders

Offline

Board footer

Powered by FluxBB