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

forum list output

Discussion in 'XenForo Development Discussions' started by -Calypso-, Jan 16, 2011.

  1. -Calypso-

    -Calypso- Member

    Ok, been trying to rundown where the output is for the main forum list (index.php?/forum.php?), I thought I found it but apparently not. I found the node_forum_level_2 template, from there looks like it's a branch off of forum_list template. So I find the $viewParams for the forum_list template, I see that in the array is $forum. Right above the $viewParams I put
    $forum['foo'] = "bar";
    I then add {$forum.foo} to the node_forum_level_2 template and nothing is displayed, what am I doing wrong?

  2. Shadab

    Shadab Well-Known Member

    For the forum home (forum-list) page:

    - Page-level template: forum_list
    - Controller class: XenForo_ControllerPublic_Index
    - Action method: actionIndex

    Adding $forum['foo'] just before the viewParams won't include that variable in the templates because the $forum variable is not directly included in the view parameters. You'll have to either (1) include the variable inside the $viewParams itself, or (2) look for another location to hook into, depending upon what you want to achieve.
  3. -Calypso-

    -Calypso- Member

    So how is node_forum_level_2 have $forum as a param?
  4. Shadab

    Shadab Well-Known Member

    A forum is a node. Just like a category, page, and a redirect link-forum. Each of these node "types" have a node handler, which decides how a node is rendered.


    ...passes the node information to the template in the form of a "$forum" variable.
  5. -Calypso-

    -Calypso- Member

    I get that part, let's say I add the field 'test' to the forum table and edit forum 1 with the text "foo", I can go to node_forum_level_2 template and put {$forum.test} in and it displays "foo", however in the file just above viewParams which has $forum in the viewParams, I can put $forum['test'] = "foo"; and it nothing is displayed.
  6. Shadab

    Shadab Well-Known Member

    I take it you want to dynamically add a key to the $forum array (which gets rendered in a node_forum_level_* template) ?
  7. -Calypso-

    -Calypso- Member

    for now yes, i also see in the node_forum_level_2 template that it has "node forum level_{$level}", guessing that level 0 would be the index, 1 would be category.
  8. Shadab

    Shadab Well-Known Member

    Extend the "XenForo_Model_Forum" model class; and override the prepareForum() method. This is the ideal place, IMO, for adding any keys to the $forum array. Core xenforo itself utilizes this method for adding the "hasNew" key.

    A "level" denotes the nesting level of a node in a node tree.
    Categories have their own node_category_level_* templates, though.
  9. -Calypso-

    -Calypso- Member

    Therein lies the confusion, if forum categories have their own then what is the purpose for the forum_{$level}? This is completely different than any other forum system code I have seen so I don't just automatically know or understand it yet.
  10. Shadab

    Shadab Well-Known Member

    Here's where XF differs from some other forum softwares. A "category" node is completely different from a "forum" node. Calling it a "forum category" only adds to the confusion. Different node types, different rendering processes. :)

    A level denotes where a node is displayed in a node tree. This level is calculated relatively.
    Wait a moment... I'm preparing an illustration which should make it clear for you.
  11. Shadab

    Shadab Well-Known Member

    On a forum-list page:


    I haven't tried any of the crazy nesting configurations myself, like a page inside a category inside a forum inside a forum inside a category; so I can't confirm how it would behave under those conditions.
    Fuhrmann likes this.
  12. -Calypso-

    -Calypso- Member

    Oh ok, I see it now. yeah, that is different, gonna take getting use to.
  13. Brogan

    Brogan XenForo Moderator Staff Member

    I have :D

    It all seems to work quite well now that level 2 nodes aren't displayed at the same level as their parent (I reported this as a bug before Beta 6).


    The actual parent node is a category but it's not displayed as it's way up the page.
  14. Shadab

    Shadab Well-Known Member

    8 levels of nesting! That. is. insane.

Share This Page