We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42380
    • 5 Posts
    thomas.stradling.adido Reply #1, 13 years, 8 months ago
    Hi,

    I am working on a project with multiple sites on one ModX (2.2.6) installation split across several contexts. The main context (the main hub site) will have a collection of news articles (using the Articles package) and ideally I would like to be able to use these articles to provide the news for the sites in the other contexts, filtered depending on the articles tags. Clicking on an article on one of the secondary sites should then load up the article on its domain.

    Currently it is correctly listing the articles based on their tags, however on the sub site when you click on an article there is a "Page not found" error.

    So to help illustrate (at least I hope it helps illustrate >,<)...

    There is hubsite.com
    This is the main site which should provide all the articles.
    So on this site an article would be hubsite.com/news-and-media/latest-news/2013/01/08/sample-article/

    There is secondarysite.com
    This should be able to list and view the articles from hubsite.com on its own domain.
    So the same article would now be on secondarysite.com/news-and-media/latest-news/2013/01/08/sample-article/

    Hope this is possible.
    Let me know if you need further clarification.

    Thanks
      • 42562
      • 1,145 Posts
      Hi,
      How did you get the tags to show up in the first place in the other top level domain (...Context). What's your call?
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 42562
        • 1,145 Posts
        Although the Articles resources are not physical files, they are nonetheless bound to a specific front-end context, which context, in your case, is bound to a specific top level domain, http_host etc. I doubt if resources can make the switch from, say, hubsite.com/news-and-media/latest-news/2013/01/08/sample-article/ to secondary.com/news-and-media/latest-news/2013/01/08/sample-article/ .

        Some people have used duplicated resources between contexts, or if possible, have used symlinks. Symlinks are more efficient. Two 'resources,' one content! Unless you tweak the Articles core, though, good luck finding a way to create a symlink for its resources.

        The tags are pointing to 404 because the link reference in the tag tpl is not absolutely absolute. It thinks you are still in the hubsite. You may alter the tpl and make them point to your original hubsite articles, but then that'll defeat the point of cross context articles.

        Please do share your solution.
          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 38878
          • 255 Posts
          Just thinking out of the box here. A very "hacky" approach would be to copy the resources in the backend DB through SQL queries like export the relevant DB entries and import them into the appropriate tables on your subsite through a cron job on each site. I know this isn't "in the spirit of the CMS", but if you can wait a bit for the cron job to run periodically, it should work. Might create some caching issues though which I will leave to the gurus to answer <.< >.>

          I'm also interested in how it works out. GL
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Articles posts are resources like any other. They can be accessed directly via their resource IDs. The trick is to find their IDs. As far as I know, their IDs are not displayed anywhere in Articles. A MIGXdb-based CMP or TV might be useful here, as you do know the ID of the parent Articles resource.

            http://rtfm.modx.com/display/ADDON/MIGXdb.Tutorials
              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
              • 38878
              • 255 Posts
              The article ID does show up in parens next to the title in the articles listing in the manager (not that it's much help unless one can programatically reference them to build the full url needed to access cross context). That's one reason I suggested the db route because once the resources are copied/synched the IDs will be there (though maybe not the same ID which is irrelevant) and the url generation would then be a non-issue in the consumer or subsite context assuming no squirrley caching issues.

              I'm curious if anyone is synching or copying select resources across modx sites. Could be a fun experiment. OR maybe just a provider and consumer web services to pull resource content from another server (securely of course). If I only had the time to play with this. Maybe 3.0 will address cross-context resourcing :0

              Quote from: sottwell at Feb 03, 2013, 01:07 AM
              Articles posts are resources like any other. They can be accessed directly via their resource IDs. The trick is to find their IDs. As far as I know, their IDs are not displayed anywhere in Articles. A MIGXdb-based CMP or TV might be useful here, as you do know the ID of the parent Articles resource.

              http://rtfm.modx.com/display/ADDON/MIGXdb.Tutorials
                • 38878
                • 255 Posts
                The article ID does show up in parens next to the title in the articles listing in the manager (not that it's much help unless one can programatically reference them to build the full url needed to access cross context). That's one reason I suggested the db route because once the resources are copied/synched the IDs will be there (though maybe not the same ID which is irrelevant) and the url generation would then be a non-issue in the consumer or subsite context assuming no squirrley caching issues.

                I'm curious if anyone is synching or copying select resources across modx sites. Could be a fun experiment. OR maybe just a provider and consumer web services to pull resource content from another server (securely of course). If I only had the time to play with this. Maybe 3.0 will address cross-context resourcing :0

                Quote from: sottwell at Feb 03, 2013, 01:07 AM
                Articles posts are resources like any other. They can be accessed directly via their resource IDs. The trick is to find their IDs. As far as I know, their IDs are not displayed anywhere in Articles. A MIGXdb-based CMP or TV might be useful here, as you do know the ID of the parent Articles resource.

                http://rtfm.modx.com/display/ADDON/MIGXdb.Tutorials
                  • 42380
                  • 5 Posts
                  thomas.stradling.adido Reply #8, 13 years, 7 months ago
                  Thanks for the replies guys. Will let you know what we find.

                  Quote from: donshakespeare at Feb 02, 2013, 01:40 PM
                  Hi,
                  How did you get the tags to show up in the first place in the other top level domain (...Context). What's your call?

                  Added a context setting called context_tag then used getResources to do:
                  [[!getResources? &parents=`115` &tpl=`news.item` &showHidden=`1` &tvFilters=`articlestags==%[[++context_tag]]%`]]
                    • 44057
                    • 2 Posts
                    I've done it this way:

                    Call the article list with this snippet:

                    [[!getResources? &parents=`33` &tpl=`sample.ArticleRowTpl` &showHidden=`1` &includeTVs=`1` &processTVs=`1` &tvFilters=`articlestags==%tag-1%||articlestags==%tag2%` ]] ,where '33' is the ID of my article-container.

                    Then, when clicked on an article, this plugin can provide the correct content:

                    https://forums.modx.com/thread/78223/tutorial-custom-aliasing-creating-cross-context-resources-revo-2-2

                    This plugin activates on page-not-found and will look on other contexts for a matching alias and will provide the article found in de correct template.

                    This way the articles will only have to be published in one context.

                    Hope it helps