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

Unmaintained How to show a forum in a page

This tutorial will explain how to show a forum (thread list) inside a page.

  1. Fuhrmann

    Fuhrmann Well-Known Member

    Fuhrmann submitted a new resource:

    How to show a forum in a page (version 1.0) - This tutorial will explain how to show a forum (thread list) inside a page.

    Read more about this resource...
     
    Gabby likes this.
  2. dorothy

    dorothy Member

    How to add page navigation?
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    Perfect.

    Thank you.
     
    Fuhrmann likes this.
  4. LPH

    LPH Well-Known Member

    I'm getting the following error.

    Code:
    Fatal error: Cannot use object of type XenForo_Template_Public as array in /path/to/community/library/NodesAsTabs/ControllerPublic/Page.php on line 21
    If I put in a bad forum id then the page will load - a good forum id gives me the above error.

    Any ideas?
     
  5. pjfry

    pjfry Active Member

    Hi I get the same Error as Iph mentioned above:

    Code:
    Fatal error: Cannot use object of type XenForo_Template_Public as array in /home/onlinegilde/public_html/library/NodesAsTabs/ControllerPublic/Page.php on line 21
    But I have no Idea what to do. Maybe someone could help!

    EDIT:

    I forget to say, that if I disable NodeAsTabs everything works just fine, so there must be a conflict. But i have just startet coding with Xenforo and I have no idea where to search for the problem.


    benny
     
  6. Digital Doctor

    Digital Doctor Well-Known Member

    Ask Jake in his NodesAsTabs thread.
     
    pjfry likes this.
  7. pjfry

    pjfry Active Member

  8. ragtek

    ragtek Guest

    It's because jack's code

    PHP:
     
    $nodeId 
    0;
    if (!empty(
    $viewParams['page']['node_id']))
    $nodeId $viewParams['page']['node_id'];
    if (!empty(
    $viewParams['forum']['node_id']))
    $nodeId $viewParams['forum']['node_id'];
    if (!empty(
    $viewParams['category']['node_id']))
    $nodeId $viewParams['category']['node_id'];
    and the code in the article
    PHP:
     
            
    /* Create the template to show the threads, with all the params requireds */
            
    $threadList = new XenForo_Template_Public('thread_list'$controllerResponse->params);
     
            
    /* Set the param 'forum' with the rendered template so we can use in our page */
            
    $response->params['forum'] = $threadList;
    use the same variable ( forum)



    you could change


    $response->params['forum'] = $threadList;

    to

    $response->params['forums2'] = $threadList;


    and in template


    <xen:require css="discussion_list.css" />
    <div class="discussionList">
    {xen:raw $forums2}
    </div>
     
    HenrikHansen, pjfry and LPH like this.
  9. LPH

    LPH Well-Known Member

    It almost works. Changed line 47 to
    Code:
    $response->params['xf_apple_forum'] = $threadList;
    And matched in Page Options.

    Sadly, this only shows the 4 threads in one forum ($threadsToShow) and does not include links to the child forums below it.
     
  10. ragtek

    ragtek Guest

    thx for confirming that this was the problem:)
     
    pjfry likes this.
  11. ragtek

    ragtek Guest

    and because of your sub forum problem=>


    check XenForo_ControllerPublic_Forum::actionIndex
    PHP:
     'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay($forum0),
    and

    XenForo_ViewPublic_Forum_View::renderHtml

    there you'll see how it works:)
     
  12. LPH

    LPH Well-Known Member

    I'm learning with everyone's help here!

    Looking at your other post now and trying to figure out what's happening in that code so I can show child forums.

    I should say:

    Code:
    $request->setParam('node_id', 114);
    The above sets the node_id ... but I'm not sure if that can be changed to an array (is that even the right term.?.. LOL)
     
  13. masterchief

    masterchief Well-Known Member

    I love this thread... I am using a page to display video via fwplayer.. works great! I cannot display forum on a page and display video on the same page. please advise

    EDIT - This code presents a video, located below the video is a message forum which is also displayed in the nodelist.

    Code:
     
    <xen:require css="discussion_list.css" />
    <div class="discussionList">
     
    <div id="container">Loading the player ...</div>
    <script type="text/javascript">
    jwplayer("container").setup({
    autostart: "false",
    flashplayer: "/jwplayer/player.swf",
    file: "/jwplayer/video.mp4",
    height: 540,
    width: 940
    });
    </script>
    <br />
     
    <div class="discussionList">
     
    {xen:raw $forum}
     
    </div>
     
    
     
  14. Matthew Hawley

    Matthew Hawley Well-Known Member

    How would I show the actual nodes?
     
  15. masterchief

    masterchief Well-Known Member

    The last DIV tag places the forum on your page

    http://newsecondcity.com/pages/theater-showcase/

    Code:
     
    <xen:require css="discussion_list.css" />
     
    <script src="http://newsecondcity.com/jwplayer/jwplayer.js"></script>
    <script>jwplayer.key="nfrBKE1rkvkQIcJb1v25jvg8rAfhdfOb9TuHrw=="</script>
     
    <div id="showcase">Loading the player...</div>
    <script type="text/javascript">
        jwplayer("showcase").setup({
            file: "http://content.bitsontherun.com/videos/3XnJSIm4-kNspJqnJ.mp4",
            width: 940,
            height: 540,
            image: "http://content.bitsontherun.com/thumbs/3XnJSIm4-640.jpg",
            title: "Sintel trailer"
        });
    </script>
    <br />
     
    <div class="discussionList">
     
        {xen:raw $forum}
     
    </div>
     
    
     
  16. arms

    arms Active Member

    Errors on 1.2

    Code:
    Server Error
    
    Missing argument 2 for XenForo_Controller::preDispatch(), called in C:\xampp\htdocs\12\library\ShowAForum.php on line 25 and defined
    XenForo_Application::handlePhpError() in XenForo/Controller.php at line 300
    XenForo_Controller->preDispatch() in ShowAForum.php at line 25
    ShowAForum::showAForumInPage()
    call_user_func_array() in XenForo/ControllerPublic/Page.php at line 46
    XenForo_ControllerPublic_Page->actionIndex() in XenForo/FrontController.php at line 337
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    XenForo_FrontController->run() in C:/xampp/htdocs/12/index.php at line 13
    missing $controllerName
     
  17. LPH

    LPH Well-Known Member

    Changed line 25 to get around the missing $controllerName but am now getting an array_slice error

    New Line 25
    PHP:
    $controllerForum->preDispatch('index''XenForo_ControllerPublic_Forum');
    Line still giving error (line 38):
    PHP:
    $controllerResponse->params['threads'] = array_slice($controllerResponse->params['threads'], 0$threadsToShow 1);
    Can comment out the above line and all is well .. otherwise .. get this error.

    Code:
    XenForo_Application::handlePhpError()
    array_slice() in ShowResearchNotes.php at line 38
    ShowResearchNotes::showResearchNotesInPage()
    call_user_func_array() in XenForo/ControllerPublic/Page.php at line 46
    XenForo_ControllerPublic_Page->actionIndex() in XenForo/FrontController.php at line 337
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    XenForo_FrontController->run() in /path/community/index.php at line 13
    
     
  18. Deepmartini

    Deepmartini Well-Known Member

    This seems pretty useful when you only have one forum and want to bypass the forum category page. Is this the best way to do that? Or is there a feature in the control panel which can eliminate the list of category nodes if there is only one (so you can go straight to the thread list)?
     
  19. bart

    bart Active Member

    I would love to see an update to this resource. It doesn't do the trick anymore...
     
  20. Digital Doctor

    Digital Doctor Well-Known Member

    @Fuhrmann - have you tested to see if it works still ? :)
     

Share This Page