We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39184
    • 24 Posts
    I'm sure this has been answered but I can't seem to find anything on it which probably due terminology. I've recently started using MODx after using Drupal so I'm learning the lingo so to speak.

    CASE: I'm overhauling an existing site to use MODx and it is currently just php files in the following structure:

    www.domain.com/department/index.html

    Where the top level can files such as index.html, about.html, etc. and the various departments can have there index.html, about.html, etc. pages as well. Essentially micro or sub sites. In addition, user privileges will be associated to specific departmental directories.

    I'm trying to find the best way to keep the same structure; however, I have only been able to find where MODx handles sub sites in a subdomain (sub.domain.com) manner. Is the functionality to accomplish structure in MODx out of the box or is there an Extra I can install to make it work.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The Resource Tree in the left column will organize your pages (referred to as "resources"). For example, you could have this structure:

      Home
      About Us
      Department 1
      ---- Home 1
      ---- News 1
      -------- Post 1
      -------- Post 2
      Department 2
      ---- Home 2
      ---- News 2
      -------- Post 1
      -------- Post 2
      Contact

      An example of this is a site I'm managing http://deafbusiness.org While this site is done in Evo, the resource structure will work in the same way for either Revo or Evo.

      There are several resources that are the same for both parts of the site, usually reflected within the main sections with "weblink" resources for linking purposes, and two "container" resources to act as parents for the two site sections. In that top level, only the two main sections are set to show in the menu, to provide the two main links in the "landing" page. However, obvious unchanging "menus" like that don't always have to use a menu snippet like Wayfinder; they can be hard-coded when they aren't going to be dynamic. For example, the two menus at the very top of the pages are hard-coded in HTML.

      With Revo, you also have "contexts" for separating sections of a site, but that's something I've never investigated myself. http://rtfm.modx.com/display/revolution20/Contexts While contexts are frequently described in terms of subdomains, they are also useful for multiple language sites or sub-sites of any kind. For example, if I had used Revo for building the deafbusiness site, I would have three contexts, the default context for "global" site content including the landing page and the registration page, one for Orlando and one for San Diego. [ed. note: sottwell last edited this post 14 years, 5 months ago.]
        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
        • 3749
        • 24,544 Posts
        Susan's advice is, as always, excellent. If you're determined to use the existing files, it's possible to write a snippet that will "include" them based on the URL of the current page, but I'd recommend against it and, if they contain mixed HTML and PHP, it won't work. In MODX all PHP code must be in snippets. In the long run, you'll be happy about this because of the separation it provides between content and presentation will make things much easier to maintain.

        In moving to MODX, mixed HTML and PHP is often handled by creating a Tpl chunk containing the HTML with placholder tags for the PHP-generated content. Then writing a snippet to set the placeholders or import them with $modx->getChunk(), which will set the placeholders for you based on an associative array you send as a second argument to getChunk() (the first being the name of the chunk).

        Hope this helps.

        Welcome to MODX. smiley


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 39184
          • 24 Posts
          Sounds like I need to explore the Contexts a bit more since it appears that will accomplish my goal. Using your info, would each dept a context?
            • 3749
            • 24,544 Posts
            TBH, I don't think I would use contexts for that. I'd just use Susan's directory structure and put the repeated content into chunks. Then just put a chunk tag where you want it to appear. It would be easier to create and maintain.

            You probably don't even need a separate template for the different departments. You could just use Template Variables for the department-specific text with an @INHERIT binding so you could set them on the department container pages and all child pages would inherit the value of the TV from above.

            If you want to have users log in and restrict them to a certain department, contexts would be a little more attractive, but I think I still wouldn't use them. I'd do it with User Groups and Permissions.



            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              When I have something like this, I'll have an ID attribute in the body tag. This is populated in various ways. In your case, I would use a TV with a default of @INHERIT, and set a value in the main container (such as 'dept1', 'dept2', etc). This way all the pages under, say, department 1, will have
              <body id="dept1">

              so in the CSS you can have sections specific for each department's pages:
              /**************************
                  Common
              **************************/
              h1{font-size:2.5em;text-align:center;}
              
              /**************************
                  Department 1
              **************************/
              #dept1 h1{color:blue;}
              
              /**************************
                  Department 2
              **************************/
              #dept2 h1{color:green;}
              [ed. note: sottwell last edited this post 14 years, 5 months ago.]
                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
                • 39184
                • 24 Posts
                Ok...I think I'm missing a key concept in the modx system. Based on Susan directory structure, how would I be able to "place or associate" the Home1 with Department1?

                In addition, how would I handle the url for that setup? I will be using friendly url's so to get "domain.com/dept1/home1.html" what would I do?
                  • 10208 ☆ A M B ☆
                  • 1,780 Posts
                  Think of the modx resource tree as a directory (folder). The concept of associating sub pages of a main page is as simple as "parent and child relations" within a directory. So, to "place" a page under a parent page you have multiple options:

                  1- create a resource (page) in the parent page (modx resource tree - right click on the parent page, choose "create > create a document/static resource/weblink/symlink here"), or...

                  2- create a resource anywhere and within the page settings select the parent you want from the dropdown list, or...

                  3- create a resource anywhere, and then drag and drop it into the parent resource you want.

                  FURLS are automatic if you want, and will use the page title by default (in system settings, under furls choose automatically generate alias). Or, you can simply type in the alias of your choice into the resource if you don't want it to be taken from the page title. Check out the FURL documentation before you change the system settings to activate FURLS. .htaccess must be enabled and configured first or the front end will throw 500 errors.

                  Furthermore, if you want to change the page order for menus (for menus, use the Wayfinder add on) you can either change the menu order in the resource manually, or simply drag and drop the resource in the document tree to where you want it.

                  As a side note, a resource will automatically become a container if you put sub(child) pages under it. It will remain a container if you remove them though, and will need to be un-ticked to revert (although it will behave the same regardless if the container box is checked or not - i.e. it doesn't matter if it's a container or not).

                  You may need to take your thinking cap off for a while, some things about MODX are just too simple and perfect as compared to other CMS :~}
                    Frogabog- MODX Websites in Portland Oregon
                    "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                    Having server issues? These guys have MODX Hosting perfected - SkyToaster
                    • 39184
                    • 24 Posts
                    Frogabog - Thanks for that information and your last statement is very true! I'm not accustomed to having to link less for simple things.

                    et. al - You all have been a big help and I may comeback so keep watching. This revamp is due in three weeks so I have my work cut out for me.