Search

Basically I am working on an extension, in order to aviod an ajax call. I have to check on some remote data to confirm if someone is online or offline and show the required information.

In order to make the script more efficient i was thinking of including this check within an extension by adding a delegate function. However I have encountered a problem when trying to pass this value to my page.

I know if a person is online/offline however I couldn't find a way to pass this value either as a javascript variable or else as a symphony variable which i can use from the template itself.

I'd like to include something of the sort <script>var status='online';</script>

The scope is to improve load time - so I don't think that creating a js file and doing addScriptToHead would do the trick...

Is this in the Frontend or the backend?

If it's Frontend (and depending on the delegate you've used) you could inject it into the param_pool and then it would be accessed via /data/param/{name-of-param or by $name-of-param

Frontend, as delegates I was thinking of using FrontendOutputPreGenerate or FrontendParamsResolve not sure which of the two would be suited most. This would take something like half .2s off our current page load time if I could make it work :)

Thanks

FrontendParamsResolve makes sense since this is where you can add parameters:

public function getSubscribedDelegates() {
    return array(
        array(
            'page'      => '/frontend/',
            'delegate'  => 'FrontendParamsResolve',
            'callback'  => 'frontendParamsResolve'
        )
    );
}

And the callback:

public function frontendParamsResolve($context) {
    $context['params']['my-param-name'] = '123456';
}

This creates a parameter in the pool accessible as Brendan says above.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details