We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28439
    • 222 Posts
    I am currently working on a shop. The shop is multi country and multilanguage for everything. Think of countries like Swiss: 1 currency, but 3 languages.
    At this moment I want to do the configuration of the shop as a module. For this I need my shop classes, to change the content of these options. The classes are in assets/snippets/shop/.
    When I include the main class in a module, I get an error:
    include_once(assets/snippets/shop/class_main.inc.php) [function.include-once]: failed to open stream: No such file or directory in....
    For me, it seems to be as the modules can only have includes based in the manager path.

    Can someone tell me if I’m right or wrong?

    Thanks
      Gone away and found a better place to stay
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Try ../assets/snippets/shop/filename.php to get the path up one from the /manager/index.php, where a module’s code is run.
        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
        • 28439
        • 222 Posts
        Thanks, Susan. I was to blind to think about this on my own.

        Also changed my initialization class, where all other includes are done and added a path parameter with a default. The default is the path for the snippets.
          Gone away and found a better place to stay
          • 27376
          • 576 Posts
          If you’re using MODx 0.9.5 or above you can use [tt]$modx->config[’rb_base_dir’][/tt] to get the assets directory. If you’re not on 0.9.5 you can use [tt]$modx->config[’base_path’][/tt] to get the base MODx path and just append assets/ to it. This will make your module forward compatible since the dev team plans to make the location of these directories customizable.
          <?php
          $base_dir = $modx->config['base_path'] . 'assets/snippets/shop/'; // Versions > 0.9.5
          
          $base_dir = $modx->config['rb_base_dir'] . 'snippets/shop/'; // Versions < 0.9.5
          ?>
          EDIT: Added example.