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

How do you hook into global header

Discussion in 'XenForo Development Discussions' started by Nudaii, Feb 23, 2016.

  1. Nudaii

    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
  2. Robust

    Robust Well-Known Member

    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.
  3. Nudaii

    Nudaii Well-Known Member


    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
  4. Nudaii

    Nudaii Well-Known Member

    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?
  5. Mike

    Mike XenForo Developer Staff Member

    You don't need/want a controller for this. Looking at adding a listener to the container_public_params event.
    Lawrence likes this.
  6. Nudaii

    Nudaii Well-Known Member

  7. Nudaii

    Nudaii Well-Known Member

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

    class RRWS_RPMarket_Listener_Ad
        public static function 
    getString(array &$paramsXenForo_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}

    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
  8. Lawrence

    Lawrence Well-Known Member

    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.
    Nudaii likes this.
  9. Nudaii

    Nudaii Well-Known Member

    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


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

    Lawrence Well-Known Member

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

Share This Page