We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I accomplish this in Revo by using a new table that tracks Resource (aka Document) id’s to multiple contexts and then use a checkbox TV/plugin to manage the entries of that table using checkboxes.  Then you can modify the query that builds the map to join to that table.  You could use the same approach, just creating a table of document id’s and additional domains they can appear in.  You just won’t have the benefit of separate document maps per domain (i.e. context) like Revo will.

    As for components, you would likely need to modify 3rd party components to be aware of this.
      • 4230
      • 28 Posts
      Thanks Jason for your reply! Right after I posted the above I started to work on a module to do that. It’s almost done, I think. Thank you for the tips. I will update here when I get it going, in case others want to use it.
      May God bless you
        • 4230
        • 28 Posts
        Jason, or anyone else, I have a question. for the siteCache.idx.php file there are three entries for documents, as far as I know:
        $d[’alias_path’] = 433;
        $a[433] = array(’id’ => 433, ’alias’ => ’alias_path’, ’path’ => ’’);
        $m[] = array(’0’ => ’433’);

        When I create the duplicate ones I’m thinking that only the $m[] entry should be created, for the original $d and $a entry are already set. Or should I change the alias path in $d? But then what about the entries in $a? The problem I’m encountering is with Wayfinder, which by the way I found that it does use documentMap ($m) but also documentListing ($d), is that it only takes distinct entries; therefore, it doesn’t display the duplicate/shared documents. I’m a little lost but I’ll keep on looking and I would appreciate any help.
        May God bless you and thank you.
          • 4230
          • 28 Posts
          The problem, as far as I can see, is that wayfinder.php, in the getdata() method, gets the data using SQL. Deeper yet, the problem is that the menu is built according to the parent of the document which is taken from the database.
          I guess that I will have to change this and take the parent from the $modx->documentMap variable. But then I run into other problems. I was then thinking of using the MODx getParent() method but I just saw that this method uses the MODx getPageInfo() method to get the parent, which takes it from the database. As far as I can see, this getParent() method does this in order to get other information like alias, title etc. I guess that I have a few options: change the getParent() method to use documentMap to retrieve the parent and db for the other info, to create another method or to try to play around with the wayfinder.php getdata() MySQL.
          Right now, without any other changes beside the siteCache file, it retrieves the shared document but it doesn’t display it in the menu because it retrieves it’s original parent. I could maybe change the MySQL so that if it finds a document that in the shared table that equals one in the current document ids to change its parent right away. But what if there are multiple entries in the shared table? Then I would need all those entries, depending on the tree. There is so much to take into consideration!
          But I run into bigger problems yet. If I write a new function or change the MODx getParent() method it will be a little difficult to get the right document, between the shared or the original one. This problem seems to be fixed, according to Jason, in the Revolution version due to the multiple domain feature, but when I want to share the same document in the same domain, then what? It seems to me that then I would need to figure out another way to know which value to get out of the multiple returned values...
          I have tried to play with the MySQL in wayfinder.php, but this wouldn’t solve the problem for the other 3rd party software... I used the UNION in the MySQL and that seemed to do what I wanted but then the levels are thrown off and it still doesn’t give me what I want.

          Sorry if I have confused anyone. If anyone out there has some ideas and thoughts let me know, I’m in need smiley I, by nature, want to find and use the best way even if it would take me longer to find it, so I would appreciate any help.

          ---- edited ---

          Here is another idea that I’m not too sure how to do or if it would be useful.
          what I could do is to check if any of the $ids exist in the shared table. If true, then use getParentIds() for the original doc, for the shared doc and to get the parents for the current doc id. There should be a way then to compare the trees in order to figure out if the original or one (or how many) of the shared docs (if there are multiple) should be used.
          • Ultimately, you need separate documentMaps. This is where contexts come in. And you share documents among contexts by populating a many-to-many table of Contexts to Documents, then simply join to this for each context when creating each documentMap. Managing the many to many is as easy as setting up a checkbox TV and a plugin to save the values to this new cross-reference table.

            There’s just no elegant way to achieve this otherwise, IMO.
              • 4230
              • 28 Posts
              Thanks Jason for the tips,
              That would be a whole lot of work for sure. Do you have some code that we could use, as a community, for the 0.9 MODx version since you got it working? It would be useful even if I could get some example code so that I don’t reinvent the wheel.
              Thank you and may God bless you
              • Quote from: AmazingDiscoveries at Jun 03, 2009, 12:26 AM

                That would be a whole lot of work for sure. Do you have some code that we could use, as a community, for the 0.9 MODx version since you got it working? It would be useful even if I could get some example code so that I don’t reinvent the wheel.
                Well, I think if I could have achieved it in 0.9.x I would have just added that instead of rewriting the entire product from scratch. You can look at the changes I made for 2.0.x (Revolution) I suppose, but since the whole code base is different, I don’t think it will help much.