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 started asking help for my problem first here: which is not really related to this problem anymore.

    I got that issue sorted but now I have more problems. I have phpbb forum from where I want to display latest topics on my main site which runs with modx. I have a .php file on the root directory where I run this piece of php code that does the trick. When I copy the same code to a snippet and try to run it I get an error message that cant find config.php (phpbb config-file), please install phpbb. My forum works without problems when accessed directly and I can display latest topics in html with my .php file in the root, but why it doesn’t work when the code is in a snippet. Is there something in modx that I haven’t considered when trying to get stuff from third-party applications? I don’t really want full forum integration, which seems to be hot topic here, but this still seemed to be best place to ask help. Thanks in advance, this is a great community! I’m quite new with modx, but I don’t know why anyone even bothers with other cms’s.. smiley

    Cheers,
    Tommy
    • The path that works fine from the root of your site may not be working from the location of the MODx index.php file. If your MODx is installed in the root of your site, it should be the same (although a relative path may not work; you may need to make it an absolute path). If your MODx is in its own directory, however, then the path has to be modified to reflect that. For example, if you have something like this for MODx
      /home/mydomain/public_html/mymodx

      and for your forum
      /home/mydomain/public_html/forum/

      the relative path from MODx would be
      ../forum/

      If your code includes a file which in turn required another file, the second file may have a problem since it’s no longer being run from its home directory, it’s being run from the MODx directory. You may find that you have to hack the second file to make an absolute path rather than a relative one, since in the two cases (from MODx and from the forum) it’s being run from two different locations.
        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
        This is probably the case. I have been trying to track where the problemmight be but I think my php-skills and knowledge of how modx actually works are not enough for this. I asked help from the phpbb forum and the guy who came up with the phpbb hack in the first place has planned to come up with a phpbb-modx integration. I’ll point him to this topic and let’s see what comes from it.

        EDIT: Here’s the link to phpbb forum: http://www.phpbb.com/community/viewtopic.php?f=71&t=587812&p=12525385#p12525385

        Thanks again for your help,
        Tommy.
          • 30711
          • 70 Posts
          So if I run a snippet in a resource and my modx is installed to root, the snippet runs in the root in terms of directories?
          • That is correct. Everything is from the relative location of the index.php file. Sometimes I find it necessary to do a little trial-and-error to get the paths right. MODX_BASE_PATH, MODX_BASE_URL, MODX_SITE_URL, MODX_MANAGER_PATH and MODX_MANAGER_URL are defined in the config.inc.php file as soon as the index.php file is loaded, and are good to use for prepending to your paths and urls.

            Keep in mind that a path is not a url; they start from a completely different root.

            When working with modules (Modules->Manage Modules) in the Manager, everything is from the relative location of the manager/index.php file.

            http://php.net/manual/en/function.include.php

            The documentation actually makes fascinating reading. There are a few major difference in how PHP 4 and PHP 5 handle included files, which may account for why sites seem to break suddenly if the hosting upgrades their version of PHP. Windows/IIS handles absolute paths beginning with / differently than *nix/Apache.
              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