combine two loops?

Hi, is there a way to combine results from two different loops?

For example, what if I want to get all articles with a keyword id of 222 plus those belonging to section 74 (not necessarily with the keyword 222)

This code below does not work since it only gets articles with id_mot=222 and also having id_rubrique=74:

<BOUCLE_articles_action(ARTICLES) {par date}{inverse}{id_rubrique=74}{id_mot=222}>

#TITRE

Of course the usual method is to generate two loops- one for id_rubrique=74 and another for id_mot=222, the problem is if you want to use only one loop for sorting and pagination purposes.

Is this not possible in SPIP? Help would be greatly appreciated.

Thanks,
Paul

Hi,

there is a criteria IN that enables you to do this

{xxxx IN a,b,c,d,…}

(In your case : {id_mot IN 222,74} )

.Gilles

On Fri, Jun 5, 2009 at 5:32 PM, Paul <npaulp@gmail.com> wrote:

Hi, is there a way to combine results from two different loops?

For example, what if I want to get all articles with a keyword id of 222 plus those belonging to section 74 (not necessarily with the keyword 222)

This code below does not work since it only gets articles with id_mot=222 and also having id_rubrique=74:

<BOUCLE_articles_action(ARTICLES) {par date}{inverse}{id_rubrique=74}{id_mot=222}>

Of course the usual method is to generate two loops- one for id_rubrique=74 and another for id_mot=222, the problem is if you want to use only one loop for sorting and pagination purposes.

Is this not possible in SPIP? Help would be greatly appreciated.

Thanks,
Paul


spip-en@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-en

For example, what if I want to get all articles with a keyword id of 222 plus
those belonging to section 74 (not necessarily with the keyword 222)

The answer is to use anti-doublons:

<BOUCLE1(ARTICLES){first criterion}{doublons x} />
<BOUCLE2(ARTICLES){second criterion}{doublons x} />

<BOUCLE_sum(ARTICLES){!doublons x}>
#TITRE
</BOUCLE_sum>

-- Fil

Thanks guys!

Gilles’ suggestion on using the IN criteria does not work for my purposes since {id_mot IN 222,74} ) can only return articles with the keywords 222 or 74. I need to get articles with the section id of 74…

Fil’s solution worked brilliantly though. I would never have thought of it since I didn’t think a negation of the doublons criteria is possible. I don’t think this is in the English documentation of SPIP.

Thanks a lot for all your suggestions! This saved me from doing some messy php coding instead.

Paul

Hi Fil,

your solution, is it mentioned in the doc ? I understand that SPIP stores the values of the doublons in a table / an array which one may examine in a third loop.

Therefore {doublons x} means "get everythin exept the objects in array x" - and {!doublons x} means get exverything in array x - am I right?

BTW is it possible to do somethin like

<BOUCLE1(ARTICLES){criterion}{doublons x} /></BOUCLE1>
<BOUCLE2(RUBRIQUES){criterion}{doublons x} /></BOUCLE2>
<BOUCLE_sum(ARTICLES, RUBRIQUES){!doublons x}{par titre}>
#TITRE
</BOUCLE_sum>

in order to obtain an ordered list of sections's and article's titles?

Thank you very much,
klaus++

Fil schrieb:

For example, what if I want to get all articles with a keyword id of 222 plus
those belonging to section 74 (not necessarily with the keyword 222)

The answer is to use anti-doublons:

<BOUCLE1(ARTICLES){first criterion}{doublons x} />
<BOUCLE2(ARTICLES){second criterion}{doublons x} />

<BOUCLE_sum(ARTICLES){!doublons x}>
#TITRE
</BOUCLE_sum>

-- Fil
_______________________________________________
spip-en@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-en

Hi,

The documentation (either french of english) is incomplete (http://www.spip.net/en_article2085.html#doublons), and doesn’t explains how (!doublons} can be used.

You can find some advanced usages of {doublons} on this page of SPIP-CONTRIB :
http://www.spip-contrib.net/Le-critere-doublons-sa-mecanique

On Sun, Jun 7, 2009 at 2:33 PM, klaus++ <klaus@spip.de> wrote:

Therefore {doublons x} means « get everythin exept the objects in array x » - and {!doublons x} means get exverything in array x - am I right?

exactly.

BTW is it possible to do somethin like

<BOUCLE1(ARTICLES){criterion}{doublons x} />
<BOUCLE2(RUBRIQUES){criterion}{doublons x} />
<BOUCLE_sum(ARTICLES, RUBRIQUES){!doublons x}{par titre}>
#TITRE
</BOUCLE_sum>

in order to obtain an ordered list of sections’s and article’s titles?

No
{doublons} can only store objects of the same type.

Your latest loop will try to create a joint query between spip_articles and spip_rubriques, but won’t work : ‹ titre › is a field that exists in each table and you must precise which on you want to use.

.Gilles

Thank you very much,
klaus++

Fil schrieb:

For example, what if I want to get all articles with a keyword id of 222 plus
those belonging to section 74 (not necessarily with the keyword 222)

The answer is to use anti-doublons:

<BOUCLE1(ARTICLES){first criterion}{doublons x} />
<BOUCLE2(ARTICLES){second criterion}{doublons x} />

<BOUCLE_sum(ARTICLES){!doublons x}>
#TITRE
</BOUCLE_sum>

– Fil


spip-en@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-en


spip-en@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-en