# (DEV) Shortcodes/Fonctions

Les variables suivantes peuvent être utilisées n'importe ou sur vos documents.twig ! par exemple il est possible de charger un morceau de template.twig dans un article même comme le ferait un Gutenberg de chez WordPress

## *Shortcodes TWIG*

{% code title="" fullWidth="false" %}

```twig
  
  // Permet de crée une srcset mobile/large et sa balise ALT
  {{ "YOUR URL LOCALE"|imgsrcset('Your ALT') }}

  Résultat: <img srcset="URL MOBILE 300w, URL LARGE 1800w" alt="Your ALT" sizes="(max-width: 1800px) 100vw, 1800px">
  
  // Permet de décoder un fichier JSON depuis Twig
  {{ "VOTRE VARIABLE JSON"|json_decode }}
  
  // Permet d'afficher la date au format: Oct 2024
  {{ date|set_date_to_country }}

  // Permet d'afficher la date au format: 13 Oct 2024
  {{ date|set_datefull_to_country }}

  // Permet de transformer les iframes Youtube.com vers youtube.nocookie.com 
    mais aussi de les mettres en loading="lazy" et de mettre les images src en data-src 
    + d'ajouter la fonction de modal "androModal" et la lazyload
  {{ contenu|lazy_content }}

  // Permet de minifier l'ensemble du contenu
  {% apply raw_file(true)|raw %} CONTENU {% endapply %}
  
```

{% endcode %}

## *Injections TWIG*

{% code title="Injection dans le <head>" %}

```twig
{% block headextends %} CONTENU {% endblock %}
```

{% endcode %}

{% code title="Injection dans le end body" %}

```twig
{% block footextends %} CONTENU {% endblock %}
```

{% endcode %}

## Variables globales et superglobales TWIG

<pre class="language-php"><code class="lang-php">/**
* SUPER_GLOBALES
*/
<strong>{{ TTLCONTENT }} // Affichera le cache_time
</strong>{{ THEME }} // Affichera le nom du theme ex: andromede
{{ RGPD_NOTICE }} // Affichera le bandeau RGPD
{{ MATOMO_ID }} // Affichera l'id de tracking Matomo
{{ LANGAVAILABLE }} // Affichera les langues CI disponibles
{{ LANGSELECTOR }} // Affichera les langues disponibles
{{ SINGLENEWS_PATH }} // Affichera le path des actualités (deprecated)
{{ COMPRESSED }} // Affichera si la page est compressée
{{ MATOMO_SCRIPT }} // Affichera le script Matomo
{{ RGPD }} // Affichera le script de RGPD

/**
* VARIABLES
*/
{{ getEnv() }} // Affichera l'environnement de CI
{{ lang('key') }} // Affichera la traduction d'une clé suivant la langue
{{ session('') }} // Variable de session CI
{{ url_to('ROUTE') }} // Affichera la route absolue de CI
{{ route_to('ROUTE') }} // Affichera la route absolue de CI
{{ csrf_hash() }} // Affichera le hash csrf
{{ csrf_token() }} // Affichera le token csrf
{{ site_url() }} // Affichera l'url du site
{{ base_url() }} // Affichera l'url du site de base (domaine)
{{ current_url() }} // Affichera l'url visible actuel
{{ view_cell('part') }} // include('part.php') charge un morceau de zone .twig
{{ cmsBlock('part') }} // include('part.php') charge un morceau de zone .twig

<strong>/**
</strong>* WIDGETS &#x26; MODULES
*/

// Affichera les derniers news avec ses paramètres + pagination
{{ cmsBlock( shortcode('recentPost'), {'langpath': 'fr', 'template': 'recent_posts', 'event': 'news', 'maxpagignation': 9, 'limit': false, 'orderby': 'DESC', 'categorieshow': true, 'showdate': true,'author': false,'categoriesJSON': '[]','showcounter': true,'showfeature': true,'colsize': 4,'limit': 9})|raw }}

// Affichera les catégories des news + pagination
{{ cmsBlock( shortcode('getcategoriesWidget'), { 'lang': 'fr', 'template': 'loop-categories', 'order': 'DESC', 'ids': '[]','maxvalues': 9})|raw }}

// Affichera les derniers commentaires sur les news
{{ cmsBlock( shortcode('recentComments'), { 'lang': 'fr','order':'DESC', 'template': 'widget-comments', 'maxvalues': 4})|raw }}

// Affichera les taxonomies + pagination
{{ cmsBlock( shortcode('archiveCPT'), { 'lang': 'fr', 'order':'DESC', 'template': 'loop-custom', 'cptids':'[]', 'showcounter': false, 'limit': false, 'ispaged': true, 'maxvalues': 6, 'colsize': 4})|raw }}

// Affichera les tags des news + pagination
{{ cmsBlock( shortcode('archiveTag'), { 'lang': 'fr', 'order':'DESC', 'template': 'loop-tag', 'cptids':'[]', 'showcounter': false, 'ispaged': true, 'limit': false, 'maxvalues': 6, 'colsize': 4})|raw }}

// Chargera les 6 derniers feeds provenant du compte Instagram
{{ cmsBlock( shortcodeCore('instagramFeed'), { "maxshow": "6" })|raw }}

// Affichera les derniers inscrits d'un forum Invision Power Board
{{ cmsBlock( shortcodeCore('InvisionForums'), { 
"endpoint": "core/members", 
"queries": "&#x26;sortBy=date&#x26;sortDir=desc",
"template": "ipb_topics", "titlewidget":"Derniers inscrits",
"cached":true })|raw }}


</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://altitude-dev.gitbook.io/andromede-cms/dev-twig-general/dev-shortcodes-fonctions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
