declarer_url_objets

This pipeline is used to generate standard SPIP URLs for the specified objects, and to calculate the correspondence between a standard URL and its matching object. These URLs may take the form:

  • spip.php?objcetXX (spip.php?article12)
  • ?objectXX (?article12)
  • or the same with .html at the end.

With the .htaccess file as supplied with SPIP and activated, URLs may also be like:

  • objectXX (article12)
  • objectXX.html (article12.html)

The URL calculated whenever we use SPIP’s URL calculation functions (the #URL_ tag or the generer_url_entite function) depend on the URL options selected within the SPIP configuration pages.

This pipeline is called in ecrire/inc/urls.php with a list of predefined objects. It accepts input parameters and produces output of a table of the list of the objects that can be used in a URL:

$url_objets = pipeline('declarer_url_objets', array('article', 'breve', 'rubrique', 'mot', 'auteur', 'site', 'syndic'));

The #URL_nom tag returns a URL for a given object type and specific object identifier (no need for declarations to do this). This pipeline is used to decode a standard URL and to identify the object type and object odentifier to which it applies. Once an object "name" has been declared , ?nameXX in the URL will enable SPIP to calculate that the object type is "name"; that the "id_name" identifier is equal to "XX", and that SPIP should therefore try to load the name.html template for the identifier in question.

The use of this pipeline can be coupled with the declaration of "table_title" in the declarer_tables_interfaces pipeline. This indicates which SQL column of the object should be relied on to create a meaningful URL.

Example

The "Grappes" plugin uses this pipeline making it possible to create URLs for the new object. #URL_GRAPPE creates a URL modifed for the object type. SPIP will then know which template to refer to when such a URL is requested: grappe.html.

function grappes_declarer_url_objets($array){
    $array[] = 'grappe';
    return $array;
}

The interface pipeline also declares the title field for meangingful URLs:

function grappes_declarer_tables_interfaces($interface){
    // [...]
    // Titles for URLs
    $interface['table_titre']['grappes'] = "titre, '' AS lang";
    return $interface;
}

Author Mark Baber Published : Updated : 29/05/10

Translations : English, français