Skip navigation.

SPIP commits

[13993] several arguments in #INCLURE or #MODELE

, , ,

#INCLURE and #MODELE accept several parameters : the syntax used for it was #INCLURE(a){b}{c}.

This syntax has been introduced in spip1.9.1. We can also read on the official documentation :


Models are not restricted to shortcuts within the text of articles. They can also be called from within a template by using the tag #MODELE{model} or [(#MODELE{model}{p1=thing,p2=whatsit}{p3=etc}|filter...)]. But this is less new, because it is equivalent to a (static) inclusion of another template (already made possible by the tag #INCLURE).



However it was quite buggy and not really homogeneous. For ex. a few abnormal differences were found between #MODELE{my_model, ..} and #INCLURE(fond=modeles/my_model){..}.

Now, the codes with parenteses and/or several braces delimited blocks are considered as deprecated : You should write instead #INCLURE{a,b,c} and #MODELE{a,b,c}.
The old syntax is still accepted.

Ex.:
#INCLURE(fond=inc-header){type=test}{env}
#INCURE{fond=inc-header, type=test, env}
#MODELE{img,lien=article5,class=logo,align=left,lien_class=important}


You can also calculate these parameters with other static content (like tags, #MODELE and #INCLURE) :
#INCLURE{fond=inc-[(#ENV{skel}|secu)]}
#MODELE{img,lien=article5,class=logo_#LANG_LEFT,align=#LANG_LEFT}


Parentheses, brakets and filters can also be used to display elements only where #INCLURE returns a content :
Ex. :
[Lastest articles in the feed #FEED_TITLE : 
  <ul>
  (#INCLURE{fond=rss-read, url=#FEED_URL, date=#DATE}|extract_post_titles)
  </ul>
]


Edit : The first argument of an INCLURE can be calculated. The common syntax indicates that filters require parentheses. But, for reason of compatibility, the following simplified syntax is accepted :
[(#INCLURE{#CHEMIN{spip_style.css}|url_absolue_css}|compacte_css)]


Creating custom tags for SPIP Howto redefine a single function

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies