Skip navigation.

exploreopera

| Help

Sign up | Help

SPIP commits

Posts tagged with "api"

[11355] Overwrite a criteria for a specific loop only

, ,

For exemple, the function critere_AUTEURS_recherche_dist() overwrites the criteria recherche for the loop AUTEURS only. The priority order is :
  1. critere_TABLE_nomcrit()
  2. critere_TABLE_nomcrit_dist()
  3. critere_nomcrit()
  4. critere_nomcrit_dist()

[11440] SQL views in the API

, , ,

3 new functions enable to create and delete views for PG, SQlite and MySQL :

  • sql_get_select() : same arguments as sql_select() but returns the query without evaluating it
  • sql_create_view($view_name, $select_request) : creates the view $view_name for the select request $select_request.
  • sql_drop_view($view_name) : drops the view.


/!\ Warning ! Yous must give an explicit name to every field prefixed with a table name or an alias. Elsewhere SQLite won't be able to read the view (which contains 'a.titre' instead of 'titre').

Example :
$sel = sql_get_select(
          array(
            'id_article'=>'id_article', 
            'titre'=>'titre'
          ),
          'spip_articles'); 
echo "requete select : $sel<br />"; 
sql_create_view('vue_nom', $sel);

$res = sql_select(array('id_article', 'titre'),'vue_nom',,,,'10');
if ($res){
   while ($r = sql_fetch($res)){
      echo "*" . $r['id_article'] . " - " . $r['titre'] . "<br />";
   }
}

sql_drop_view('vue_nom');

What is a SPIP pipeline ? It's a hook

, ,

During the normal execution of several commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to change the values of function arguments before any other call, and allow for a post-processing treatment that will always change the function result.

Exemple :
function prefix_treatment($flow) {
   /* add something to the flow */
   $flow .= 'This is some html code';
   return $flow;
}


plugin.xml defines the implemented hooks with a list of <pipeline> tags:
<pipeline>
 <nom>point_entree</nom>
 <action>fonction</action>
 <inclure>fichier.php</inclure>
</pipeline>


  • <nom> : name of the hook (from a list defined in ecrire/inc_version.php)
  • <action> : function name without it's prefix
  • <inclure> : file name that defines the previous function. It's name must be prefix_action


(src : http://doc.spip.org/@Tuto-Se-servir-des-points-d-entree)

[11355] overwrite a criterion for a specific loop only

, ,

For exemple critere_AUTEURS_recherche_dist() will overwrite the criterion recherche for the loops over AUTEURS. The priority order is :
  1. critere_TABLE_nomcrit
  2. critere_TABLE_nomcrit_dist
  3. critere_nomcrit
  4. critere_nomcrit_dist

[11289] Ajax without coding in SPIP

, , , ...

<INCLURE{fond=fond/ajax}{fond_ajax=mon_fond}{id_truc=xx}..>

includes the template and ajaxifies all it's links.

By default, the javascript variable "ajaxbloc_selecteur" is used. It transforms into ajax call each link that corresponds to the jquery selector '.pagination a,a.ajax'.

An ajax call refreshes the template's result by restauring it's #ENV, plus some parameters in the url.
When a refresh occurs, the bloc's opacity is changed to 50% and it's class to 'loading' (this div is automatically created)
The loaded part is cached on the browser with javascript. It also can be preloaded by adding the class 'preload' to the corresponding links.

That's all !

(src : http://thread.gmane.org/gmane.comp.web.spip.devel/46569)

Howto detect if a plugin is activated ?

, , ,

in PHP :
Each plugin defines a constant corresponding to it's execution path
if (defined('_DIR_PLUGIN_XXX')){ ... }


inside a template :
#PLUGIN and conditionnal evaluation does your job !
[(#PLUGIN{XXX}) doSomething ]

[10805] private area : object pages in templates

, , ,

Big change in the private area API :

afficher_contenu_objet() is simplified and know uses a customizable template for every (standard?) table.
The result of this template uses a pipeline ('afficher_contenu_objet'), and so plugins can modify it .

This commit creates a directory 'dist/contenu/' that contains article.html, breve.html, etc.
Really usefull for customisation of the private area, no ?