Fork me on GitHub

Modules with sub directories  Bottom

  • Im actually working on more of a port of a regular PHP script to a PN module, but i have wondered this in the past too.

    How is it possible for modules that are larger than normal to work with files that have multiple subdirectories.

    Maybe i need view a file that is in modules/blahblah/foo/bar/login.php

    I have no idea how that would be accessed by URL and still work.
  • I've always found that anything that is accessed by a browser is always in the root directory of any well designed script, and these files then include others located in sub-directories. Presumably that is not the case with your script...

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • When you have large modules its going to have to be the case in order to keep anytype of good directory organization of the module.
  • I have used sub directories in a couple of my modules, and haven't ran into any difficulties. The thing to remember is that your functions are being called my the main index.php, so you have to define your module's directory accordingly.

    There's an API function to get the URL for the current site (I'm too lazy too look it up right now).

    For include, fopen statements, etc, you can prepend your modules/mymodule/mydir to your file to make sure it pulls from the proper location. So, you can fopen(modules/mymodule/mydir/subdir/login.php), for example, if you need to do something like that.

    Calling the function to return the current working directory should return the file system path to index.php (aka, the root of postnuke).
  • Well, again, that requires running everything out of the module root directory again. Wish we could somehow keep security up, but run modules as such: domain.com/modules/News/index.php or whatever. Would make it so much easier to port scripts and have more friendly urls. (with our without shorturls)

This list is based on users active over the last 60 minutes.