0

To add some common ground. I need to transfer 3 variables from a module to my template when the sites loading. In my module I get 3 links to specific images and they need to be included in the template. So I tried to do in my module:

$session = Factory::getSession();
$session->set('image1', $value);

and in my index.php:

$session = Factory::getSession();
$variable = $session->get('image1');

The issue is that this only works if I refresh my page. I understand that the template is loaded first and the module is loaded second so the template reads the variable before it is set. The question is: Is there away around this? How can I accomplish what I want to?

4
  • What are you trying to accomplish?
    – Sharky
    Sep 20 at 6:07
  • @Sharky Like it said in the text: I need to get some variables (text) from a module to the template. I just need to transfer some variables nothing more but it seems nearly impossible. The other way around (from module to template) its easy and straight forward. Sep 20 at 20:40
  • Yes, but for what purpose? Without knowing it's hard to come up with a solution. You already know the current approach doesn't work. Maybe the logic should be moved to a plugin or maybe you could use client-side (Javascript) solution. It is also possible to programmatically retrieve modules and render them without jdoc tags in the template, although it's not a good approach either.
    – Sharky
    Sep 20 at 20:59
  • @Sharky I have a "News" module that retrieves the last 3 articles with the tag "news". In order to render the article images correctly in my styling they need to be included as a background-image in my template because I handle all css in my template. Thats why I need to get 3 varaibles from my module to my template. I mean there has to be some way without breaking my coding structure or using obscure workarounds.... Sep 21 at 20:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy