Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2010-02-03 23:03:18

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

Ok I will explain it in this way:
I got two sections: ‘Agenda’ and ‘Audio’
‘Agenda’ is a section where I’m posting articles of all the events,
and ‘Audio’ is a section that I’m posting articles of many livesets some are from events and some are not.
So I want to display a list of articles (events), but only the ones that have the same posted date as the articles from the ‘Audio’ section.

now I do able to display a list from ‘Agenda’ on ‘Audio’.
but the catch is that not all the events’ dates does have livesets.
so I want to limit the list only to these that have the same posted date as the articles from ‘Audio’.

What a nice story before bed time, isn’t it? lol ;)

Last edited by THE BLUE DRAGON (2010-02-03 23:07:35)

Offline

#278 2010-02-03 23:26:03

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: smd_if: Generic multiple if condition tests

So you don’t just need to check against one posted date, but against a list of posted dates? Hmm… maybe you need smd_each as well.

Offline

#279 2010-02-04 00:05:16

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

Maybe, if you say so o_O
Here is a link to the site where you can see on what I’m talking about.
(Yea it’s a Dutch site ;] )
on the right side you can see the “Select a category” list, and in that list there are all the past events.
and for now only two of them are having livesets (the last two: 13.12.08 & 04.04.09),
and the rest have no livesets for now.
if you click on one that have livesets it will take you to the latest article (liveset) from that date and will present to you a list of related sets from that date.
in this way my client don’t need to create any categories and all that, in this way it will be all automatically.

and this is what output that list for now:

<txp:article_custom section="agenda" limit="999">
<a href="<txp:article_custom section="audio" limit="1" category="livesets" month='<txp:posted format="%Y-%m-%d" />'>/<txp:article_id /></txp:article_custom>" onfocus="if(this.blur)this.blur()">
<txp:article_image thumbnail="1" />
<div class="audio_agenda">
<txp:custom_field name="Event Name" />
<br />
<txp:posted format="%d.%m.%y" />
</div>
</a>
</txp:article_custom>

and somehow I need to add smd_if/each to that code or other code? to do the trick.

Last edited by THE BLUE DRAGON (2010-02-04 00:09:35)

Offline

#280 2010-02-04 10:23:20

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

Re: smd_if: Generic multiple if condition tests

THE BLUE DRAGON wrote:

I want to display a custom articles list of section “b” that have the same posted date as the articles of section “a”.

Hmmm, looking at your initial code in post #277 I can see why it’s not working, but I’m not quite sure how to make it work a) reliably, b) efficiently. Let me think out loud for a moment:

<txp:article_custom section="a" limit="999">
<txp:smd_if field="section, posted" value="b, <txp:posted format='%Y-%m-%d' />">

This will fail because you are only listing articles from section “a”, thus when you test to see if the section = “b” it will never be TRUE. The test for ‘posted’ is not even considered.

Els was right that your quotes needed to be swapped round. Her suggestion in post #279 will work if you get the logic right, but I think she’s also correct that you might not need a plugin. In my limited understanding of what you’re trying to do, here’s how I think it should run (albeit not very efficiently):

<txp:article_custom section="agenda">
   <txp:article_custom section="audio" month='<txp:posted format="%Y-%m-%d" />'>
      // Format your second list here
   </txp:article_custom>
</txp:article_custom>

What have I missed?


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

#281 2010-02-04 10:47:11

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

Re: smd_if: Generic multiple if condition tests

Ohhhh…thanks now I got it!

I need 3 article_custom tags (ok, 4) and not only 2, this is how:

<txp:article_custom section="agenda" limit="999">
   <txp:article_custom section="audio" category="livesets" limit="1" month='<txp:posted format="%Y-%m-%d" />'>
      <txp:article_custom section="agenda" limit="1" month='<txp:posted format="%Y-%m-%d" />'>
         <a href="<txp:article_custom section="audio" limit="1" category="livesets" month='<txp:posted format="%Y-%m-%d" />'>/<txp:article_id /></txp:article_custom></a>
      </txp:article_custom>
   </txp:article_custom>
</txp:article_custom>

Thanks for all the help and sorry for posting all of this in this plugin topic.

but what a nice trick, isn’t it? (embarrassed)

Offline

#282 2010-02-04 10:50:09

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

Re: smd_if: Generic multiple if condition tests

THE BLUE DRAGON wrote:

Thanks for all the help and sorry for posting all of this in this plugin topic.

No probs, but if you have a lot of articles your page might slow down significantly with 4 nested article_custom tags! If this happens, consider converting the logic to a single smd_query for the sake of your database and visitors’ patience ;-)


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

#283 2010-02-05 17:53:04

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: smd_if: Generic multiple if condition tests

@Gil Using sections for totally different content is the absolutely right TXP approach but I wouldn’t use it to mix different content inside ONE presentation (which is kind of weird from the TXP logic of ‘shut off’ sections).

Seriously … the parsing of your multi-level nested code example will work but slow down the site.

Easy: I would add the audio content right in the article as an additional div which will flow somewhere (left, right, up, down) with the ‘original’ article. If there is data it shows, if not no output will be generated.

A little bit more complex: Add the audio content right in the article through custom fields (or use body for agenda and excerpt for audio).

Multiple articles: Basically you can call related articles hard coded by article ID or by keyword or category relation to show up in your article context.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#284 2010-02-19 08:31:59

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

I have this code:


<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
		<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
			<txp:variable name="pagenumber" value='<txp:variable name="firstpage"/> '/>
		</txp:smd_if>
		<txp:smd_if field="my_custom_field_pagenr operator="ge" value='<txp:variable="lastpage">'/>
			<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
		</smd_if>
		<a href="?c=<txp:page_url type="c" />&month=<txp:page_url type="month" />&pg=<txp:variable name="pagenumber" />"><txp:custom_field name="pagenr"/></a>
		&nbsp;</li>
	<txp:else />
	<a href="?c=<txp:page_url type="c" />&month=<txp:page_url type="month" />&pg=<txp:page_url type="pg" />"><txp:custom_field name="pagenr"/></a></li>
	</txp:smd_if>

the first smd_if works fine.
When the totpages is 17 it true.
Then the current page (custom field pagenr) is 11 then firstpage will be 6.
The second smd-if is then false.
But the thirht smd-if (<txp:smd_if field=“my_custom_field_pagenr operator=“ge” value=’<txp:variable=“lastpage”> is never carried out.

Can you tell me why this happens ?

Roelof

Last edited by roelof (2010-02-19 08:33:16)

Offline

#285 2010-02-19 08:45:46

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

Re: smd_if: Generic multiple if condition tests

Not sure if related, but you have a </smd_if> on your code, when it should be </txp:smd_if>.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#286 2010-02-19 09:06:34

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Manique.

I changed it but it seems not related.
I still get this tagtrace :

<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
						[<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >: true]
						<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
							[attribute 'value']
							<txp:variable name="firstpage"/>
							[/attribute]
							[<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>: false]
						</txp:smd_if>
						<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
							[attribute 'value']
							<txp:variable name="lastpage"/>
							[/attribute]
					</txp:smd_if>

Roelof

Offline

#287 2010-02-19 09:13:24

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

Re: smd_if: Generic multiple if condition tests

roelof

Try adding the name attribute to your txp:variable in the 3rd smd_if tag.

<txp:smd_if field="my_custom_field_pagenr" operator="ge" value='<txp:variable name="lastpage">'/>

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

#288 2010-02-19 09:25:23

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

When I changed it to :L

<txp:smd_if field="my_custom_field_pagenr operator="ge" value='<txp:variable name="lastpage"/>'/>

I get this tag trace :

<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
						[<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >: true]
						<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
							[attribute 'value']
							<txp:variable name="firstpage"/>
							[/attribute]
							[<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>: false]
						</txp:smd_if>
						<txp:variable name="lastpage"/>
						<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
							[attribute 'value']
							<txp:variable name="lastpage"/>
							[/attribute]
					</txp:smd_if>

Roelof

Offline

Board footer

Powered by FluxBB