Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
I needed to retreive the system.site page.front config value from js on front end (progressive decoupling)
I first thought of using hook_page_attachments_alter() and inject the value in drupalSettings
But then i built a little module which provide any "simple config" through REST resource
I'll paste the rest resource plugin bellow but i have some questions :
{#
/**
* @file
* Default theme implementation for message entities.
*
* Available variables:
* - $content: An array of comment items. Use render($content) to print them all, or
* print a subset such as render($content['field_example']). Use
* hide($content['field_example']) to temporarily suppress the printing of a
* given element.
* - $title: The (sanitized) entity label.
* - $url: Direct url of the current entity if specified.
* - $page: Flag for the full page state.
I'm currently using some jQuery on my Drupal 8 website, but my function is running on every request and the lists generated by the script are duplicated. I tried to use .once() to avoid this problem, without success.