[ar] [ca] [cpf] [de] [en] [es] [fr] [it]

This is where you can ask questions about the SPIP cms.

Topics : 254 Topics solved :  31 %

41 visitors now


Home > Forums about SPIP >  Creating your templates > #GET or PHP in Loops Criteria / Boucle criteres

#GET or PHP in Loops Criteria / Boucle criteres

by magahugu - 27 June 2015 13:24 - Replies : 3

Hello

I’m hitting a major limitation trying to filter a BOUCLE dynamicly. THis means that one criterion passed to the boucle should be either a PHP variable or a SPIP #GETvariable tag.

As this is not possible, what other ways are there to filter the content?

Thank you,
Urs


  • Hello, Can you insert on exemple off what you re tryin (between cadre tags)

    <cadre class="spip">***Code here***</cadre>

  • < #2 > #GET or PHP in Loops Criteria / Boucle criteres ˆ
    by magahugu - 27 June 2015 18:58

    OK, here we go:

    Note: Variable $a has been previously defined to be 1.

    1. #SET{variable,<?php echo $a: ?>}
    2.  
    3. <BOUCLEn(AUTEURS){id_auteur=#GET{variable}>
    4. #NOM
    5. </BOUCLEn>

    Download


  • Ok, spip haven’t got limitations, but you must know what is the good practices to write templates and where you can use php.

    - You must not use php in .html template.
    - but you can use php function as filter

    ex:

    1. [(#LISTE{one,two,three,four}|implode{-})]

    - you can use function in mes_fonctions.php and use it as filter too.

    To answer to your question
    What is the $a value? if it is the current id_auteur you can use #SESSION

    if you want have a look on the current session data you can use

    1. [<pre>(#SESSION|unserialize|print_r{1})</pre>]

    so to loop just on the current user

    1. <BOUCLE_cur_user(AUTEURS){id_auteur=#SESSION{id_auteur}}>
    2. #NOM
    3. </BOUCLE_cur_user>

    Download

    I don’t know if I give you a good answer, but if you tell me what is the $a value i can give the best way to get it.

    Hope you understand my bad english :)




Answering the question

« #GET or PHP in Loops Criteria / Boucle criteres »

Keywords

You can tag this forum page with the keywords that you think are the most appropriate. This will help future visitors to find answers more quickly.


Installation, updates

Using the private area

Administration, management and configuration of your site

Creating your templates

Who are you?
  • Log in Register