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

Bought xen today, have a customization question

Discussion in 'Styling and Customization Questions' started by jt2011, May 16, 2012.

  1. jt2011

    jt2011 Active Member

    I'm switching from phpbb to xen, its a huge change but after a few hours i'm getting the hang of it. I have a question regarding the index page of the site.

    What I would like to do is have columns for specific forums on the front page. Each is in a column and each column has a 120x120 image with a link to the forum (the columns are 120x120) under the image I would like to list the last X amount of recent posts. The posts would just show the title and author avatar and the time (ago) it was posted.

    [cat img 1] [cat img 2] [cat img 3] [cat img 4]
    [cat 1 post] [cat 2 post] [cat 3 post] [cat 4 post]
    [cat 1 post] [cat 2 post] [cat 3 post] [cat 4 post]
    [cat 1 post] [cat 2 post] [cat 3 post] [cat 4 post]
    [cat 1 post] [cat 2 post] [cat 3 post] [cat 4 post]

    Is this feasable?

    I understand I am probably looking at making a custom page and that is perfectly okay with me, I just need some guidance to get the ball rolling. Any sugestions, input or links would be great.

    1. How do I create a new page and make it the index page of the site?
    2. How do I list the last X recent posts for a specific forum?

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You could use the "forum_list_nodes" template hook. Here is a code example for using a template hook:


    That way you can execute your own PHP code to build your custom category list and then overwrite the existing $contents with your own.

    You can also use custom CSS to change the style of the node list:

    Admin CP -> Appearance -> Templates -> EXTRA.css

    But CSS doesn't help you list the recent posts. That requires PHP code like a template hook listener.
  3. jt2011

    jt2011 Active Member

    thanks for the info

    ok so trying to make a page and this is much much more complicated than I anticipated.
    How are you supposed to know all the custom functions?
    Is there an official document or something that I can read to learn more about the templating and functions?
    I'm starting to think I made the wrong choice of forum due to the complexity, at least with phpbb I could easily make new pages and modify templates. So far with Xen I have to open dozens of different files and it is impossible to keep track of it all.
  4. Hackfall

    Hackfall Member

    I'm also very interested in this.

    Jake, The code snippet you pointed to is impenetrable because I don't understand the context or what the statements apply to. I feel a bit like when I'm looking at some code I wrote myself a few months earlier and wish I'd put some notes in. I write old style procedural Perl and know a bit of php but could really do with a worked example to get an understanding.

    Has anyone done a tut on this?

  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can edit the templates too:

    Admin CP -> Appearance -> Templates -> forum_list

    That is the template for the index page. But PHP code is still required to fetch custom content like the recent posts. Other forums might call them addons or plugins. In XenForo they are called listeners. That is what you use to execute custom PHP code without having to modify the files. But it does require programming ability.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The listener is a class and function, but within the function you can use regular procedural code. $contents contains the rendered HTML for that hook location on the page. You can modify the HTML, overwrite it, append to it, etc by working with that variable.
  7. jt2011

    jt2011 Active Member

    @jake bunce
    thank you for the clarification
    I'm going through Floris's tutorials and it is making things more understandable
  8. Hackfall

    Hackfall Member

    I gave up on Drupal because I couldn't get my head around the intricacies of doing things programatically but XenForo is too good to give up on. I can see I'm going to have to switch my head from replacement tags in templates to listeners, classes and functions to do the things I want to make XenForo do.

    Where are Floris's tutorials?
  9. Hackfall

    Hackfall Member

  10. jt2011

    jt2011 Active Member

  11. Hackfall

    Hackfall Member

    Floris likes this.

Share This Page