Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2010-02-02 19:05:01

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

Re: smd_if: Generic multiple if condition tests

Hey!
I will like to know how to do the next thing:
I got two sections “a” and “b”,
and I want to display a custom articles list of section “b” that have the same posted date as the articles of section “a”.

so will it be something like this?:

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

Offline

#278 2010-02-03 20:54:43

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

Re: smd_if: Generic multiple if condition tests

Any idea what do I need to put into the ‘field’ attribute?
the ‘posted’ is not working, and do I need to add any ‘operator’ attribute please?

Offline

#279 2010-02-03 22:25:20

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

Re: smd_if: Generic multiple if condition tests

THE BLUE DRAGON wrote:

the ‘posted’ is not working,

Does it work if you change

value="b, <txp:posted format='%Y-%m-%d' />"

to

value='b, <txp:posted format="%Y-%m-%d" />'

Offline

#280 2010-02-03 22:29:37

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

Re: smd_if: Generic multiple if condition tests

no it’s not :(

Offline

#281 2010-02-03 22:38:19

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

Re: smd_if: Generic multiple if condition tests

No, I didn’t expect it to work ;) I don’t quite understand what you are trying to do. Are you refering to an individual article page, displaying one article in section a, and you want a list of articles in section b with the same posted date? If so, I don’t think you need the plugin.

Offline

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

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
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

#283 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

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

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
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

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

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
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

#288 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

Board footer

Powered by FluxBB