1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to access container_public_params in templates?

Discussion in 'XenForo Development Discussions' started by viewfinder, Nov 3, 2010.

  1. viewfinder

    viewfinder Member

    Please bear with me here, just learning how to set some data that can be used in the template.

    I've created a really basic Add-on that has a container_public_params listner, as such:

    PHP:
    class Sample_Listener_Test
    {
        public static function 
    getString(array &$paramsXenForo_Dependencies_Abstract $dependencies)
        {
            
    $params['teststring'] = 'hello world';
        }
    }
    I am assuming this is the correct way to add an addressable string into the public params so that it can be referenced in the container? The string is intended to be used for dressing the logo_block.

    Now how do I reference this parameter in the header/logo_block template? Have I missed the point all together?

    Any pointers would be very much appreciated.
     
  2. Shadab

    Shadab Well-Known Member

    Use this format to access a variable in a template: {$variable}

    Code:
    <div class="pageContent">
    	...
    	{$teststring}
    </div>

    hello_world.png
     
    Umit likes this.
  3. viewfinder

    viewfinder Member

    Thanks Shadab, works well. It really was that simple, and here I'm expecting something more complex!

    Cheers!
     
  4. Vladislav Rastrusny

    Vladislav Rastrusny Active Member

    How do we determine the place in code where this hook is called? Supposing I want to pass the specific parameter only on a page with thread list?
     
  5. Shadab

    Shadab Well-Known Member

    For passing the parameters only on a specific page, you could try to extend the controller and override the action that's being called for building that page. In your case, that would probably be XenForo_ControllerPublic_Forum and actionIndex.
     
    Umit likes this.
  6. Vladislav Rastrusny

    Vladislav Rastrusny Active Member

    I see. So, this hook allows only site-wide parameter injection, right?
     

Share This Page