We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36876
    • 3 Posts
    Hey Ho

    I'm totally new to Modx! Php is not my prefered language, too. Ok. I've got no idea of php...

    Actually I was trying to get a multi context site running. many single pages (each one context) and one masterpage (another context) which should summarize sum pages of the other contexts. Multi Context was easy and seems to work, but getRessources wasn't showing my content.

    content in each context is separated in folders.
    - news
    -- 2011
    --- document
    --- document

    so getResources should start from 'news' and collect all data below.
    In the same context this works well, from another context it's not working. I found that
    $modx->getChildIds($parent, $depth);
    is used wrong. It's only searching children in the current Context.

    It's quite late now, so maybe not everything I'm saying makes sense.
    I made a really quick and dirty hack to this.
    In getResources Snippet.php I removed lines 107-118 (chapter "multiple context support")
    and added them (modified) on line 82. Ah yes, lines 82-85 are also moved. Now it looks like (starting line 82):
    /* multiple context support */
    if (!empty($context)) {
        $context = explode(',',$context);
        $contexts = array();
        foreach ($context as $ctx) {
            $contexts[] = $modx->quote($ctx);
    		foreach ($parents as $parent) {
    			$pchildren = $modx->getChildIds($parent, $depth, array("context"=>$ctx));
    			if (!empty($pchildren)) $children = array_merge($children, $pchildren);
    		}
        }
        $context = implode(',',$contexts);
        unset($contexts,$ctx);
    } else {
        $context = $modx->quote($modx->context->get('key'));
    	foreach ($parents as $parent) {
    		$pchildren = $modx->getChildIds($parent, $depth);
    		if (!empty($pchildren)) $children = array_merge($children, $pchildren);
    	}
    }
    if (!empty($children)) $parents = array_merge($parents, $children);



    So there are two things I'd like to ask:
    - Is there a way to file bugs for getResources?
    - Can somebody with knowlegde of php AND modx please verify my bug, and find a solution thats not dirty hacked like mine? (it's not really performant to have getChilds in foreach{foreach}... but i spent too much time to figure this out. php is not my world and modx is all new, so I'm not the guy to make this perfect.


    Hope someone can reconstruct this bug and find a nice solution for it.

    Kind regards,
    martin
      • 27708 MODX Staff
      • 2,502 Posts
      getResources project bugs can be filed at https://github.com/opengeek/getResources/issues. I don't know if this is a bug or not but I am a little skeptical and think it may be a property setting. It certainly could be a bug though. I'd seek more feedback for sure.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 26575
        • 57 Posts
          christian seel - www.christianseel.com
          web developer & designer at chsmedien.de
          twitter: @christianseel / @chsmedien
          • 3749
          • 24,544 Posts
          Did you include the &context property in your getResources tag?
            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
            • 36876
            • 3 Posts
            hi

            thank you for your replies.

            Yes I included the &context property in the tag. But it's never used to get children from another context. As far as I remember (have no access to my development environment at the moment) getChildIds is used wrong.
            There is a getChildIds call in getRessources, but this call ignores any given context from &context. So getChild can't know which contexts to search.

            Or do you mean something else with property settings?

            Kind regards,
            Martin
              • 22303 MODX Staff
              • 10,725 Posts
              How do you have children of a Resource in a different Context from their parent? That is not supported by the framework AFAIK.
                • 36876
                • 3 Posts
                Hi

                Oh no, that was a misunderstanding.
                The parent is also in the different context.
                so we are in context A
                and the structure in B is something like:
                - parent
                -- child
                --- child of child
                -- child
                ...

                we call getRessources with &context='A,B' &parents='parent, maybeParentInContextA'

                what happens now is, that getChild only gets children of maybeParentInContextA, because it is never called with information about context B.

                hope this is clearer.

                Kind regards,
                martin
                  • 26575
                  • 57 Posts
                  @Jason if you would like to see this in a real modx installation, contact me...
                    christian seel - www.christianseel.com
                    web developer & designer at chsmedien.de
                    twitter: @christianseel / @chsmedien
                    • 22347 ☆ A M B ☆
                    • 29 Posts
                    Was this issue ever resolved? We've come across this same issue.
                    Wanting to display documents in one context being pulled from another context. The documents are organized in a series of containers inside a parent container.

                    The call across context works if you are pulling documents directly from that parent folder and the documents exist directly in that container. However, in this situation, we are looking to pull all documents (depth is 5), and it only brings back the initial depth.

                    Thanks.
                      "Give a company a website, and they will be successful for now...
                      Give a company a long-term web strategy, and they will be successful for a lifetime."

                      Company Website: http://www.orbitalalliance.com
                      Company Blog: http://www.orbitalalliance.com/blog
                      • 22303 MODX Staff
                      • 10,725 Posts
                      I'm still not clear on the issue here; I can get all the children from parents in multiple contexts just fine in my tests. If the issue is that you have a symlink in context A pointing to a container in context B that it will not automatically "follow the symlink across contexts" to get children of the symlink target, then that is not supported by the code currently.