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.
Leonidas is a -legendary- Belgian chocolate company founded in 1913. Today, the brand is present in 32 countries and has more than 1000 points of sale. The company has a strong reputation and has been certified purveyor to the Belgian royal Palace.
In my case I want to write some javascript code inside the paragraph-something.hmtl.twig taking elements from the theme variables and then putting this javascript attached to the bottom of the page. Something like:
{{ attach_library('my/code') }}
but being able to write the code dynamically and not link to a js file pre-comp.
I am trying to redirect visitors if it is their first time on site.
I beleive in drupal 7, this could be done on itialization using init().
Im using a gated content module to check with cookies if a user has already visited the site before. But this uses JS and is executed once dom is fully loaded.
Im trying to find a way to detect at the earliest point. Before any content is load if possible.
What sort of function should I be looking at?
I know is a generic question but just looking for a starting point. Thanks