We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Hi there,

    I´m trying to include the forum in MODx, but it doesn´t work at all. Because the errors are not very explanatory, I tried to include it on a test file, which worked well. But the MODx-include doesn´t. Perhaps some can give me a hint...

    What I´ve done (test-file):

    I created a testfile (test.php) with the header information (the HTML stuff) and put it in the root of the MODx installation (because in the end the forum shall be called linked index.php?id=7&req=main e.g.) while the forum lies in assets/snippets/unb/. I changed some paths in the board.conf.php (lib_path, base file etc.) of unclassified forum and wiped out the HTML head of the _head tpl (unclassified has a template engine). After some trying this works very smooth, so I can call the forum with mydomain.de/test.php, all links are displayed as mydomain.de/test.php?req=main etc. So the inclusion works.

    But:

    Inclusion works, but when I try it on modx, it doesn´t. I created a snippet [[unb]], where I put the same include as in test.php. I put the call in a page and that´s it. Header should be build by MODx (which doesn´t matter for my problem I think) and the rest of the paths should be correct. But the only output I get is:

    UNB Error: No server set for database connection.

    This is a UNB created error. I don´t know why this doesn´t work. Perhaps some of you can explain me how inclusions work in MODx. I thought the inclusion works like on a "usual" .php file. The paths should be okay. Am I totally wrong? Do I have to rewrite all database functions of that forum? Is there something I didn´t mention? Is there something MODx requires? I took a look a Susan´s docman, but there is everything changed to MODx db-functions, I thought I can use the ones of the forum.

    I am totally stuck... :’(

    Greetz Marc
      • 32241
      • 1,495 Posts
      Could you post the test.php code that yuo use for your snippet?
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 17883
        • 1,039 Posts
        test.php (in the root folder):

        <?php
        //test-include
        $base_path='assets/snippets/unb/';
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
        <title>MODx Deutschland Forum</title>
        <base href="http://localhost:8888/modx_de/" />
        <link rel="stylesheet" href="<?php echo $base_path; ?>unb_lib/designs/modern/css/common.css.php" type="text/css" />
        <link rel="shortcut icon" href="<?php echo $base_path; ?>unb_lib/designs/modern/img/favicon.ico" type="image/x-icon" />
        <link rel="alternate" type="text/xml" href="test.php?req=rss" title="All posts RSS feed" />
        <link rel="top" href="test.php?req=main" title="Übersicht" />
        </head>
        <?php 
        include('assets/snippets/unb/forum.php'); 
        ?>


        works well.

        Snippet:

        $base_path='assets/snippets/unb/';
        include($base_path.'forum.php'); 
        


        As I said, the header stuff (CSS and so on) comes later, first I want to see anything undecided

        I also tried this with another testfile (test2.php) with a simple echo(’hello world’); in it, an d includet this one via snippet. Works well.

        I am afraid that there is something wrong with the database connection of the forum. But I definitely don´t know why the inclusion via test.php works and the one via snippet not at all...

          • 32241
          • 1,495 Posts
          I never use UNB before, but there is a big chance that the code from MODx is not compatible with UNB.
          Try to use function, and run UNB inside a function. This is what the phorum integration use, to avoid clash between phorum and the major/main application.

          function testunb() {
            $base_path='assets/snippets/unb/';
            include('assets/snippets/unb/forum.php'); 
          }
          testunb();
          


          Let see whether it works or not.
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
            • 17883
            • 1,039 Posts
            No, same thing sad
              • 17883
              • 1,039 Posts
              Did some debugging with lots of echo "hello world"... wink

              Obviously the global var of the unb isn´t correctly build. As I said, the forum works so it must have something to do with a modx conflict. Is there something that limits the size of (global) variables by modx?
                • 22303 MODX Staff
                • 10,725 Posts
                If you are including files from the forum inside a snippet, this will not work, unless the system sends it’s output to a variable you can capture and return in your snippet. Snippets do not allow direct output via methods such as echo. The output buffer on snippets is localized and discarded, and the actual output of the snippet is returned. I bet you can simply start a new buffer inside your snippet to capture the output buffer from the script you are including, and then assign it to your return variable. e.g.

                ob_start;
                include "foo/bar/foobar.php";
                $content= ob_get_contents();
                ob_end_clean();
                return $content;
                


                Give that a try and see if that works for you. I haven’t tried it, but it should theoretically work. undecided
                  • 17883
                  • 1,039 Posts
                  Hi Jason,

                  thx for your answer. I put it in my snippet like this:

                  $base_path=('assets/snippets/unb/');
                  ob_start;
                  include "assets/snippets/unb/forum.php";
                  $content= ob_get_contents();
                  ob_end_clean();
                  return $content;


                  It´s the same with that. I don´t actually know where to search. I have some output and this is the thing which is letting the thing go weird. With my test-include (in the root folder without modx-enviroment) everything works fine. If I put it in a snippet, the forum call loses some variables at some point. I tested through the forum files with lots of test-echos and it seems that at one special point the global var from the forum (the one with the settings) gets broken and loses information. It´s at a call of a session handling function of the forum. Perhaps there are some conflicts? But I don´t know why...

                  I also tried to define a test-variable right before this call and tried to print it in the function, but it isn´t forwarded to the function. Head is smoking and I don´t even know where to search. The fact that I´m not a coder doesn´t make it better laugh

                  Greetz Marc
                    • 32241
                    • 1,495 Posts
                    Quote from: OpenGeek at Feb 22, 2006, 06:44 PM

                    If you are including files from the forum inside a snippet, this will not work, unless the system sends it’s output to a variable you can capture and return in your snippet. Snippets do not allow direct output via methods such as echo. The output buffer on snippets is localized and discarded, and the actual output of the snippet is returned. I bet you can simply start a new buffer inside your snippet to capture the output buffer from the script you are including, and then assign it to your return variable. e.g.

                    Jason, I think echo does work inside the snippet. I use echo on some of my snippets and it works just fine. I think snippet will do just fine using either return or echo. I have phorum integration, and it works without having to capture the output into output buffer and return it inside snippet.

                    From what I can understand, I believe UNB doesn’t play really nice to be run inside MODx. That’s one of the thing though, when integrating phorum, I can see that the code is built with flexibility in mind, which refer to having phorum to be integrated inside another major CMS system or other major Open Source system, while I haven’t really look inside UNB, but I believe they are not really thinking about that.

                    Marc, your best bet will be to ask this question in their forum, let see whether they are willing to explain it to you in detail on things that need to be done for running their phorum inside other system.

                    Feel free to report back to here, when you’ve heard a reply from them wink
                    Sorry for being laxy in looking at UNB forum code grin
                      Wendy Novianto
                      [font=Verdana]PT DJAMOER Technology Media
                      [font=Verdana]Xituz Media
                      • 17883
                      • 1,039 Posts
                      Marc, your best bet will be to ask this question in their forum, let see whether they are willing to explain it to you in detail on things that need to be done for running their phorum inside other system.

                      Well, I already did, and the developer is very patient smiley We´ll figure out tomorrow. I think it´s a very good forum, the functions are very handy and it is very good skinnable (with an own template machine). So I think the rest of the code should be also "okay" (modern) as far as I can see. I WANT this forum in modx laugh Particularly because I already spent two days for trying that and skinning the whole thing for the modx germany site wink

                      Greetz Marc