We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25979
    • 178 Posts
    Any ideas with &resources parameter guys?

    Anybody?

    Regards,

    Mike
      //Why use windows since there is a door?//
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: salik at Aug 17, 2010, 02:39 PM

      Any ideas with &resources parameter guys?
      Maybe if you provide some information about how you are using it.
        • 11055 ☆ A M B ☆
        • 3,112 Posts
        here we go the bugfix for getResources 1.1.0-pl:
        from:
        <?php
        /* set default properties */
        $tpl = !empty($tpl) ? $tpl : '';
        $includeContent = !empty($includeContent) ? true : false;
        $includeTVs = !empty($includeTVs) ? true : false;
        $processTVs = !empty($processTVs) ? true : false;
        $tvPrefix = isset($tvPrefix) ? $tvPrefix : 'tv.';
        $parents = isset($parents) ? explode(',', $parents) : array($modx->resource->get('id'));
        $depth = isset($depth) ? (integer) $depth : 10;
        $children = array();
        


        become:
        <?php
        /* set default properties */
        $tpl = !empty($tpl) ? $tpl : '';
        $includeContent = !empty($includeContent) ? true : false;
        $includeTVs = !empty($includeTVs) ? true : false;
        $processTVs = !empty($processTVs) ? true : false;
        $tvPrefix = !empty($tvPrefix) ? $tvPrefix : 'tv.';
        $parents = !empty($parents) ? explode(',', $parents) : array($modx->resource->get('id'));
        $depth = !empty($depth) ? (integer) $depth : 10;
        $children = array();
        

        for remainder, it’s been listed again in here : http://github.com/opengeek/getResources/issues/issue/12

        And here is the modX::getChildIds() work around proposal:
        from
        <?php
            public function getChildIds($id= null, $depth= 10) {
                $children= array ();
                if ($id !== null && intval($depth) >= 1) {
                    $id= intval($id);
                    if (isset ($this->resourceMap["{$id}"])) {
                        if ($children= $this->resourceMap["{$id}"]) {
                            foreach ($children as $child) {
                                $processDepth = $depth - 1;
                                if ($c= $this->getChildIds($child, $processDepth)) {
                                    $children= array_merge($children, $c);
                                }
                            }
                        }
                    }
                }
                return $children;
            }
        

        Become this:
        <?php
            public function getChildIds($id= null, $depth= 10) {
                $children= array ();
                if ($id !== null || $id === '' && (int)$depth >= 1) {
                    if (isset ($this->resourceMap["{$id}"])) {
                        $children= $this->resourceMap["{$id}"];
                        foreach ($children as $child) {
                            $processDepth = $depth - 1;
                            if ($c= $this->getChildIds($child, $processDepth)) {
                                $children= array_merge($children, $c);
                            }
                        }
                    }
                }
                return $children;
            }
        
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
          • 36541
          • 222 Posts
          Quote from: salik at Aug 17, 2010, 02:39 PM

          Any ideas with &resources parameter guys?

          The reasoning behind [tt]&resources[/tt] can be found in the previous support thread and GitHub issue 5. In short:

          Allow to select resources directly (not their parents) and add them to the collection by, say, [tt]&resources=`id[, id]`[/tt]? It should be possible to collect only resources of choice.

          That will allow to collect resources into a hand made list and, in special case, return value for a single resource.

          BTW, do support threads get created anew with every new version of snippet?
            This is the web: the only thing you know about who will come is that you don't know who will come.
            • 36541
            • 222 Posts
            Quote from: Rodent at Aug 13, 2010, 05:56 PM

            for me, the &resources parameter does not WAD.

            documentstructure is
            id25 (resource as container)
            -id26 (resource)
            -id27 (resource)

            snippet call:
            [[!getResources? &parents=`25` &resources=`27` &tpl=`rbox` &includeContent=`1`]]


            but what is being output is resource id26 and id27...

            Is this a bug, or is it me doing something not in the correct way?

            In your case the call should be:

            [[!getResources? &parents=`dummyId` &resources=`27` &tpl=`rbox` &includeContent=`1`]]


            [tt]&parents=`dummyId`[/tt] should not be needed, however its still required by snippet (see PHP error when &parents is unset issue). As workaround I set it to a dummy resource with no children.
              This is the web: the only thing you know about who will come is that you don't know who will come.
              • 36541
              • 222 Posts
              Issue: Allow empty &sortby to keep explicit order

              It’s not possible to keep explicit order in output, which is useful with [tt]&resources[/tt]. My use case is a hand-picked collection of items, where order is important.

              I expect it with [tt]&resources=`2, 4, 3`[/tt] and [tt]&sortby=``[/tt].
                This is the web: the only thing you know about who will come is that you don't know who will come.
                • 36541
                • 222 Posts
                Issue: Allow chunk parameters and property sets in template calls

                That would particularly useful for altering template chunks for use with [tt]&tplFirst[/tt], [tt]&tplLast[/tt] etc., where it would allow to use a single chunk with a variable to define, say, [tt]class[/tt] attribute.
                  This is the web: the only thing you know about who will come is that you don't know who will come.
                  • 11055 ☆ A M B ☆
                  • 3,112 Posts
                  Quote from: gadamiak at Aug 18, 2010, 05:11 AM

                  [tt]&parents=`dummyId`[/tt] should not be needed, however its still required by snippet (see PHP error when &parents is unset issue). As workaround I set it to a dummy resource with no children.
                  It’s been resolved by my debug above. Empty &parents will use page’s self ID, as it is intended to be from the beginning.
                    Rico
                    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                    MODx is great, but knowing how to use it well makes it perfect!

                    www.virtudraft.com

                    Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                    Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                    Maintainter/contributor of Babel

                    Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
                    • 36541
                    • 222 Posts
                    Quote from: goldsky at Aug 18, 2010, 07:40 AM

                    It’s been resolved by my debug above. Empty &parents will use page’s self ID, as it is intended to be from the beginning.
                    Your patch resolves the unset &parents error issue. However, for intended use of "&resources" the dummy resource is still required. Notice, the patch has not been applied yet.
                      This is the web: the only thing you know about who will come is that you don't know who will come.
                      • 1061
                      • 81 Posts
                      This snipet is NEED AT LEAST TWO PROPERTIES: parents and tpl !!!

                      in this variation, no needed patching