We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30711
    • 70 Posts
    I have a piece of php code in a test.php file that is located in my root directory. It gets latest topics from a phpbb forum and it works fine. When I copy the code to a snippet and call it on my website, I get error:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: require_once(forum/common.php(770) : eval()’d code) [function.require-once]: failed to open stream: No such file or directory
    Error type/ Nr.: Warning - 2
    File: /home/content/t/e/s/test/html/manager/includes/document.parser.class.inc.php(770) : eval()’d code
    Line: 5

    I understand whats the problem (or I think I do), but I don’t understand how to point to forum directory in my snippet. Or is there something else wrong here? My forum is in root/forum/

    The beginning of the snippet is here:

    <?php
    define(’IN_PHPBB’, true);
    $phpbb_root_path = (defined(’PHPBB_ROOT_PATH’)) ? PHPBB_ROOT_PATH : ’forum/’;
    $phpEx = substr(strrchr(__FILE__, ’.’), 1);
    require_once($phpbb_root_path . ’common.’ . $phpEx);
    require_once($phpbb_root_path . ’includes/functions_display.’ . $phpEx);
    require_once($phpbb_root_path . ’includes/functions_admin.’ . $phpEx);
    require_once(’functions.’ . $phpEx);
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That ../forum/ part is wrong, unless your MODx installation is not in the root. You could always do something like this
      define('PHPBB_ROOT_PATH', '/home/domain/www/forum/');
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 30711
        • 70 Posts
        Thanks,

        I replaced

        $phpbb_root_path = ...

        with this:

        $phpbb_root_path = (defined(’PHPBB_ROOT_PATH’)) ? PHPBB_ROOT_PATH : $modx->config[’base_path’]."forum/";

        But it still says:

        Error: require_once(/home/content/t/e/s/test/html/forum/common.php(770) : eval()’d code) [function.require-once]: failed to open stream: No such file or directory
          • 30711
          • 70 Posts
          Thanks for help sottwell, I got it working, but the main problem is somewhere else, not in modx side of things, so I’ll start to look help from somewhere else. Thanks anyway smiley

          Tommy