We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51331
    • 3 Posts
    I just started with modx, I am getting familiarized to modx world day by day. I have a very wonderful project which I want to implement using modx. Its about creating similar looking websites for a college with same presentation (html,css,js) but different data/content for faculty, departments, courses staff etc for each campus on a single top level domain.

    www.collegexyz.com/campus1 // website for campus 1
    www.collegexyz.com/campus2 // website for campus 2
    www.collegexyz.com/campus3 // website for campus 3

    I actually wanted to know what is the best approach in modx to handle this scenario. I learned about contexts but its about replicating presentation, meaning showing multiple faces of a site with similar content. But the scenario described above is the opposite of what contexts are meant to solve, its about same presentation but different content. Surely, we will use contexts when our client demands to customize the user interface for their needs by creating a clone of "web" context and using a different base template but that's a good consideration for future cases and even easy to implement with built-in modx support in form of contexts.

    The straight forward solution which comes to my mind in this case is:

    1. create a table called sites/subsites with structure such as SiteID, Name, DateCreated

    SiteID-----Name---------DateCreated
    1-----------Campus1------27 Feb 2014
    2-----------Campus2------15 Jun 2015

    2. Use the SiteID with each record in other tables like departments, faculty, courses, staff etc.

    StaffID----------Name----------------SiteID
    1---------------John Dane--------------1
    2---------------Marry Parsad-------------1
    3---------------Roberts Smith---------------2

    3. When ever someone requests the

    www.collegexyz.com/campus1/staff

    then we will parse the URL, fetch the campus id and pass it to the snippet responsible for querying database and returning the results belonging to that site only using joins. But it can be difficult to manage with a single database as the number of campuses increases from a few to 30 or 40 and can have performance issues and other matters.

    Alternatively, We can create different databases for each site with identical schema in that case it will be only a matter of fetching the name of the site from URL (i.e campus1) and pass to snippet to use as database name while while querying the database but that requires creating a separate database for each campus website.

    I want to know what is the actual term used in technical community to identify the above scenario so i can search the material, how to best handle the given scenario in general php development and in particular case of modx. It will be pleasure if any one can point me to any articles, tutorials and books both in the php and modx community which discuss and provide multiple solutions to the problem discussed above. You are welcome to ask questions if there is anything ambiguous.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You have misunderstood contexts. Contexts have their own resources, thus their own content. As far as the template goes, resources are assigned whatever templates you wish, and each context can have its own default template specified in its context settings, or you can simply use the site default template. That can be found in the main System Settings.

      What you want to do is exactly what contexts were developed for. You can use a single domain with subdirectories, you can use subdomains, or you can use completely separate domains. The trick is to initialize the context that is wanted. This can be done with .htaccess rules and/or with a plugin. I prefer to use a plugin like XRouting. http://modx.com/extras/package/xrouting
        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
        • 51331
        • 3 Posts
        I am really sorry as i mentioned before i am new user of this platform, as far as my understanding of the context is that it will replicate all the resources when you clone it, this is straight forward for a website with only static content but what if the pages for staff, faculty, departments and courses are dynamic means the data comes from a database for each f these pages from the respective tables. Are you saying that when ever someone replicates the context, it also creates a new database for the new context, additionally i don't want to create any sub-directories i want to handle this scenario using single modx installation. Till now i have not explored how the custom data needs are handled in the modx, So to make it clear what happens to that part when you clone a context, i try to explore that part and waiting for your reply.
          • 4172
          • 5,888 Posts
          I think, the idea, creating only one site-structure and use that same site-structure for all campuses is a good one.
          And put all the campus - related stuff into custom-tables.
          They could be on different databases for each campus or in the same database with a campus-id on each table.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            If you duplicate a context, then yes, the duplicated resources will have the same content, but each one would be a separate resource in the database. Each one would need to be edited to have the content you want.

            Every resource has a field, context_key, which indicates what context it belongs to. So all resources in all contexts are in the same site_content table.
              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
              • 51331
              • 3 Posts
              I think the idea presented by Bruno17 is what i was trying to say, its not possible for us to just duplicate the context and edit the resources to fill it with campus related stuff, because we will also provide an admin area for each campus so they can upload the campus related stuff with an easy to use interface. In short we are not going provide the staff of each campus access to modx manager interface for other reasons too, including uploading of schedule, results, news, events related data on a daily basis which will require us to provide a full time technical persons to edit the resource in the modx interface.

              So I will describe again the solution i want to provide:

              "it will use just one-site structure and create custom tables to store the campus related/specific stuff in single/multiple databases, and also provide an intuitive admin user interface so users can login/add/update/remove content on their own".

              So what are the options available in the modx platform to best implement the above scenario, do any one have written any plugin for modx. I was searching in google for multi-site development i found word-press and joomla multi-site plugins for creating a network of similar looking websites which duplicate both site structure and database as per your requirement, any suggestions, articles and tutorials which discuss the above scenario in modx or php community.
                • 4172
                • 5,888 Posts
                Its possible, to manage everything within one and the same Manager for all kind of admins/editors.
                You can hide everthing, what one user isn't permited to see/edit.

                I would create the site-structure with resources (only the admins could have access to the resource-tree)
                Then create some CMPs (Custom-Manager-Pages, I create them allways with help of MIGXdb), where they can manage the campus-stuff, stored in different custom-tables.
                I think, I would go with the campus-id - column on each table.

                Then you can have a plugin at OnPageNotFound, which sets the campus-id and forwards to the correct resource, depending on the URL.

                so

                www.collegexyz.com/campus1/staff (not existing MODX-URL invokes the System-Event OnPageNotFound)

                would internally forward to

                www.collegexyz.com/staff?campus_id=1

                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!