How do you hook into global header

Nudaii

Well-known member
howdy all , i have found how to food into indiviual things like thread/forum etc but how cna i hook a custom controller to show on index page of forum or every page
 
The page layout is controlled by the template PAGE_CONTAINER, if that's what you mean. If you want to add something to every page, you should probably add it in the appropriate place in that template.
 
howdy

sorry for not being clear, I am looking for a way to expand the params of the global header so I can use my own variables from an array, on custom pages, thread or forum I have found right one to set listener for, but unsure which handles global
 
howdy all , i have found how to food into individual things like thread/forum etc but how can i hook a custom controller to show on index page of forum or every page
lol just noticed auto correct changed the first hook into food xD

@Lawrence any ideas on which controller to extend to target the page_container with new params?
 
You don't need/want a controller for this. Looking at adding a listener to the container_public_params event.
 
Made some progress on this but hit a roadblock. when using this code

PHP:
<?php
class RRWS_RPMarket_Listener_Ad
{
    public static function getString(array &$params, XenForo_Dependencies_Abstract $dependencies)
    {
       // Run Queries on the Database
        $advertNum = rand(1,4);
        $advertQuery = $db->fetchAll("SELECT * FROM `xf_advert_rp` WHERE `ad_id` = $advertNum");
        $params = array('advertParam' => $advertQuery);
       }
}
?>

Ir works as far as putting correct array data to template {xen:helper dump, $advertParam}

Code:
array(1) {
  [0] => array(5) {
  ["ad_id"] => int(1)
  ["ad_title"] => string(10) "Test Title"
  ["ad_text"] => string(12) "Test Message"
  ["ad_image"] => NULL
  ["ad_owner"] => string(7) "Richard"
  }
}

However it kills off all ajax/java functions on site when enabled, can you spot my mistake?

@Mike @Lawrence
 
Made some progress on this but hit a roadblock. when using this code

PHP:
<?php
class RRWS_RPMarket_Listener_Ad
{
    public static function getString(array &$params, XenForo_Dependencies_Abstract $dependencies)
    {
       // Run Queries on the Database
        $advertNum = rand(1,4);
        $advertQuery = $db->fetchAll("SELECT * FROM `xf_advert_rp` WHERE `ad_id` = $advertNum");
        $params = array('advertParam' => $advertQuery);
       }
}
?>

However it kills off all ajax/java functions on site when enabled, can you spot my mistake?
Hi, :) From your quoted code:
$params = should be something like this: $params['adventParam'] = $advertQuery; (or use array_merge).
The way you have it now $params is being reassigned as a new array.
 
works perfectly now! thanks @Lawrence.

btw you may get a kick out of my use for this, its to allow in character adverts for the role plays on my site :D

aka

"Visit the Starlight Inn"
Best prices and least chance of death anywhere near the darklands! just alittle fun thing for the writers :D
 
works perfectly now! thanks @Lawrence.

btw you may get a kick out of my use for this, its to allow in character adverts for the role plays on my site :D

aka

"Visit the Starlight Inn"
Best prices and least chance of death anywhere near the darklands! just alittle fun thing for the writers :D

I never even thought about that for my site, that is a fantastic idea that would bring realism to a RPG site, :)
 
Back
Top Bottom