We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27843
    • 170 Posts
    Hi,

    can I somehow control sorting throught URI ? The best if it’s possible throught GET and if it’s how ?

    Thank you for advices
      • 7231
      • 4,205 Posts
      2 options, use a wrapper or support snippet to get the GET data OR use the Request extender. Both will do the same thing.

      Tip: don’t like the ditto var names, you can edit them in the extender file  wink
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27843
        • 170 Posts
        Quote from: dev_cw at Jan 08, 2009, 05:53 AM

        2 options, use a wrapper or support snippet to get the GET data OR use the Request extender. Both will do the same thing.

        Tip: don’t like the ditto var names, you can edit them in the extender file wink

        great, that is exactly waht i need, but i have already created snippet(wrapper) for this job, but i utilize this in future, thank you
          • 27843
          • 170 Posts
          I have tried rqeust extender and don’t work for me, ditto call looks like this:
          [!Ditto? &id=`ShopCategories` &language=`slovak-utf8` &parents=`23` &display=`10` &tpl=`dittoShop` &paginate=`1` &paginateAlwaysShowLinks=`1` &sortBy=`categoriesTags` &sortDir=`asc` &extenders=`summary,dateFilter,request` &tagData=`categoriesTags` &tagDelimiter=`,` &removeChunk=`basketPrice`!]<br /><p class="articlesCount" &good=`orderBy`><br />Zobrazujem <strong>[+ShopCategories_start+]</strong> - <strong>[+ShopCategories_stop+]</strong> z <strong>[+ShopCategories_total+]</strong> Noviniek <br /></p><br /><div class="dittoPages"><br />[+ShopCategories_previous+] [+ShopCategories_pages+] [+ShopCategories_next+] <br /></div><br />


          and URI look like this:
          http://www.4golf.sk/kategorie?ShopCategories_orderBy=pagetitle%20ASC<br />http://www.4golf.sk/kategorie?ShopCategories_orderBy=pagetitle ASC<br />http://www.4golf.sk/kategorie?ShopCategories_orderBy=pagetitle


          but any sorting, where the problem could be ?

          Thank you for advices
            • 7231
            • 4,205 Posts
            I think that the problem is most likely that the extender does not know how to handle the new orderBy parameter. Not sure if the extender has been updated since it was introduced. But I could be wrong  grin

            Also make sure that the snippet is uncached [! !] otherwise the url value will not be read.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 27843
              • 170 Posts
              Th snippet is uncached, i hoped that this is 100%, request extender needs little tunning wink
                • 27843
                • 170 Posts
                So I have discovered, that the URI must look like this:
                http://localhost/4golf.sk-modx/vyrobcovia?ditto_ShopProducers_orderBy=pagetitle%20ASC


                And the the parameter is passed to the to the right array, thus to this array:
                $variables[$saneName] = trim($value);


                The whole code in request extender looks exactly like this:
                foreach ($_REQUEST as $name=>$value) {<br />	$saneName = str_replace($dittoID, "", substr($name, 6));<br />	$dID = ($dittoID == "") ? true : strpos($name, $dittoID);<br />	if ((substr($name, 0, 6) == "ditto_" && $dID) && !in_array($saneName,$bad) && ($good == false || in_array($saneName,$good)) && !ereg("[\^`~!/@\\#\}\$%:;\)\(\{&\*=\|’\+]", $value)){<br />		if ($stripTags) $var = $modx->stripTags($value);<br />		$variables[$saneName] = trim($value);<br />	}<br />}


                But if all conditions are accomplished I get this error:
                « MODx Parse Error »<br />MODx encountered the following error while attempting to parse the requested resource:<br />« PHP Parse Error »<br /> <br />PHP error debug<br />  Error: 	Invalid argument supplied for foreach()	 <br />  Error type/ Nr.: 	Warning - 2	 <br />  File: 	E:\htdocs-ganymede\4golf.sk-modx\assets\snippets\ditto\classes\ditto.class.inc.php	 <br />  Line: 	158	 <br />  Line 158 source: 	foreach ($orderBy[’parsed’] as $item) { 


                So I have debugged whole request extender and I have discovered, that the URI must look like this:
                http://localhost/4golf.sk-modx/vyrobcovia?ditto_ShopProducers_sortBy=pagetitle&ditto_ShopProducers_sortDir=ASC


                There is inconsitency between orderBy in newest Ditto 2.1 and old parameters, so sortBy and sortDir, I think that this should be join together, so the URI have to look like this:
                http://localhost/4golf.sk-modx/vyrobcovia?ditto_ShopProducers_orderBy=pagetitle%20ASC


                I don’t know if it’s necessary ditto_ShopProducers_orderBy, but if not it could be simply ShopProducers_orderBy

                If author of this snippet give me some info, so I can create patch for this.