We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12491
    • 90 Posts
    I, am trying to combine Formit, Switch, GetresourcesTag and Migx to make rolldowns with selection and sort options for products in migx webshop. I,m having difficulties in fetching data from within migxtv fields to sort on.

    I really would like some help on this, it is a mush harder as i thought it would be to combine these migxtvvalue's with getresources.


    Goal is a dropdown sorting on price, stock, ordernumber, name, date.
    And all vise versa or a change direction checkbox/selectionbox

    sortby name and date are easy and are working
    but combining them with the sortbyTv value's is a problem couse they are fieldvalue's wthin a Migxtv
    How do i call these value's from Getresources?

    TV name is Fancy-Product-data
    The field we want is Prijs1


    Switched part within getresources:
    &sortdirTV=`DESC`  
    &sortbyTV=`[[!getImageList? &docid=`[[+id]]` &tvname=`Fancy-Product-data` &placeholdersKeyField=`[[+Fancy-Product-data.Prijs1]]` &tpl=`@CODE:[[+Prijs1]]`]]`






    [[!FormIt? 
    &hooks=`redirect`
    &store=`1`
    &emailTpl=`[[*id]]`        
    &redirectTo=`[[*id]]`
    ]]      
    	  
    [[!FormItRetriever]]
    
    <form name="form2" id="form2" method="POST" action="[[~[[*id]]]]">
    
            <select name="limit" id="limit" onchange="this.form.submit('[[~[[*id]]? &scheme=`full`]]?key=tags&tag=[[*tag]]');">
              
                <label for="limit">Aantal resultaten:</label>
                  <option value="0" [[!+fi.limit:FormItIsSelected=`0`]] >All</option>
                  <option value="1"  [[!+fi.limit:FormItIsSelected=`1`]]>1</option>
                  <option value="3" [[!+fi.limit:FormItIsSelected=`3`]]>3</option>
                  <option value="6" [[!+fi.limit:FormItIsSelected=`6`]]>6</option>
    
              </select>
        
            </div>
    
    
    
    
            <div class="sort span6"><b>Sorteer Op:</b>
              <select name="sort" id="sort" onchange="this.form.submit();"> 
    
      <label for="sort">Aantal resultaten:</label>
    
    
           <option value="a" [[!+fi.sort:FormItIsSelected=`a`]] >Default</option>
                <option value="b" [[!+fi.sort:FormItIsSelected=`b`]]>Name (A - Z)</option>
                <option value="c" [[!+fi.sort:FormItIsSelected=`c`]]>Name (Z - A)</option>
                <option value="d" [[!+fi.sort:FormItIsSelected=`d`]]>Date (n - o)</option>
                <option value="e" [[!+fi.sort:FormItIsSelected=`e`]]>Date (o - n)</option>
                <option value="f" [[!+fi.sort:FormItIsSelected=`f`]]>Prijs ( ↑ )</option>
                <option value="g" [[!+fi.sort:FormItIsSelected=`g`]]>Prijs ( ↓ )</option>
                <option value="h" [[!+fi.sort:FormItIsSelected=`h`]]>Voorraad ( ↑ )</option>
                <option value="i" [[!+fi.sort:FormItIsSelected=`i`]]>Voorraad ( ↓ )</option>
                <option value="j" [[!+fi.sort:FormItIsSelected=`j`]]>Bestelnummer ( ↑ )</option>
                <option value="k" [[!+fi.sort:FormItIsSelected=`k`]]>Bestelnummer ( ↓ )</option>
               
              </select>
            </div>
    
    
    
    
    
    
    </form>



    [[!getResourcesTag? 
      &element=`getResources` 
      &elementClass=`modSnippet`  
      &tpl=`PRODUCT`
      &parents=`[[UltimateParent? &topLevel=`4`]]` 
      &depth=`2`
     
     [[!switch?
        &get=`[[!+fi.sort]]`
        &c1=`b` &do1=` &sortby=`{"pagetitle":"ASC"}``
        &c2=`c` &do2=` &sortby=`{"pagetitle":"DESC"}``
        &c3=`d` &do3=` &sortby=`{"publishedon":"ASC"}``
        &c4=`e` &do4=` &sortby=`{"publishedon":"DESC"}``
        
        &c5=`f` &do5=`  &sortdirTV=`[[!getImageList? &docid=`[[+id]]` &tvname=`Fancy-Product-data` &placeholdersKeyField=`[[+Fancy-Product-data.Prijs1]]` &tpl=`@CODE:[[+Prijs1]]`]]``
        &c6=`g` &do6=``
        &c7=`h` &do7=` &sortdirTV=`DESC`  &sortbyTV=`Artikelvariant-1-voorraad``
        &c8=`i` &do8=` &sortdirTV=`ASC`  &sortbyTV=`Artikelvariant-1-voorraad``
        &c9=`j` &do9=` &sortdirTV=`DESC`  &sortbyTV=`Artikelvariant-1-nummer``
        &c10=`k` &do10=` &sortdirTV=`ASC`  &sortbyTV=`Artikelvariant-1-nummer``
        &default=` &sortby=`{"pagetitle":"ASC"}``
      ]]
      &limit=`[[!+fi.limit]]`  
      &includeContent=`1`  
      &showHidden=`1`  
      &hideContainers=`1`
      &pageVarKey=`page`
      &processTVs=`1`
      &includeTVs=`1`
      &processTVList=`Productimage,Fancy-Product-data`
      &includeTVList=`Productimage,Fancy-Product-data`
      &cache=`0`
    ]]
      Sommige mensen hebben aan een half woord genoeg
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      MIGx values are JSON-encoded strings. You'll need a snippet to parse the string (easiest to convert it to an array with http://php.net/manual/en/function.json-decode.php) and pick out the bits you want, then use that snippet as the property value for the sorting.
        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
        • 12491
        • 90 Posts
        Thanks Susan,
        I understand wat you mean.
        but i,m a not a snippet writer , i just don't have the skills for Object PHP.
        Liniair i can do some things outside of Modx but i mostly use packages and third party snippets.


        Can you give me a example of a such a nippet and the way to call it within a getResourcesTag call?

        It would be a great help

        Hurby









        [ed. note: hurby last edited this post 13 years, 11 months ago.]
          Sommige mensen hebben aan een half woord genoeg
          • 4172
          • 5,888 Posts
          can't understand what this part should do:

          &sortbyTV=`[[!getImageList? &docid=`[[+id]]` &tvname=`Fancy-Product-data` &placeholdersKeyField=`[[+Fancy-Product-data.Prijs1]]` &tpl=`@CODE:[[+Prijs1]]`]]`


          This

          [[!getImageList? &docid=`[[+id]]` &tvname=`Fancy-Product-data` &placeholdersKeyField=`[[+Fancy-Product-data.Prijs1]]` &tpl=`@CODE:[[+Prijs1]]`]]


          is trying to get the TVvalue of the TV Fancy-Product-data of the Resource with the id, stored in the placeholder [[+id]] and will return an undelimeted list of the values of the field 'Prijs1' of all records

          &placeholdersKeyField=`[[+Fancy-Product-data.Prijs1]]`
          what should this part do here?

          If the placeholder [[+id]] has a correct value of a resouceid you will get a result with something like that, say the prices are 120,45,78,90

          &sortbyTV=`120457890`
          


          doesn't make much sense for me.

          Can you explain your situation a bit more?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 12491
            • 90 Posts
            Hi Bruno,

            Together with my brother we made a resource based shop using Migx.

            Before migx we where using a lot of single tv's to store all value's (stock, prices, variations, productnumers and images) of a products and the variations of it. It became very slow and we build the new shop around migx. We are very satified with it. So thanks for MIgx! Bruno.

            Now we are trying to make friendly indexpages of all products within a level with a lot of nice sorting oprtons. We combined Getresource tag with formit to sort on date, title and tags and besides that, set a limit for the amout of products to show. This we have working.

            We are now we are trying to add sorting on price, stock and ordernumber but these values are in the Migx TV. We would like to sort on those value'sto: from low to high and vise versa.

            But we got now idea how to call them from there to achieve this. So don't be guided by our crazy call, it madness. I,m a bad programmer, my brother is more familiair with PHP liniair code. So after trying
            all kinds of ways we gave it up resulting in this post.

            Any Help would be very appriciated.





              Sommige mensen hebben aan een half woord genoeg
              • 4172
              • 5,888 Posts
              ok, can you give your formtabs of this MIGX-TV and a typical content of it (the stored value/json-string in the db) of one product/resource.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 12491
                • 90 Posts
                Sorry for the delay Bruno, was very tired and fell asleep.
                Here the data you ask for.



                Here the formtabs

                [{
                    "formname":"Fancy-Opties"
                    ,"formtabs":[{
                        "caption":"Fancy Opties"
                        ,"fields": [{
                            "field":"doel"
                            ,"inputTV":"hiddenTV"
                        }]
                    },{
                        "caption":"Artikelvariant-1"
                        ,"fields": [{
                            "field":"Image1"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving1"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-1-omschrijving"
                        },{
                            "field":"Voorraad1"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-1-voorraad"
                        },{
                            "field":"Prijs1"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-1-prijs"
                        },{
                            "field":"Bestelnummer1"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-1-bestelnummer"
                        }]
                    },{
                        "caption":"Artikelvariant-2"
                        ,"fields": [{
                            "field":"Image2"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving2"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-2-omschrijving"
                        },{
                            "field":"Voorraad2"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-2-voorraad"
                        },{
                            "field":"Prijs2"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-2-prijs"
                        },{
                            "field":"Bestelnummer2"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-2-bestelnummer"
                        }]
                    },{
                        "caption":"Artikelvariant-3"
                        ,"fields": [{
                            "field":"Image3"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving3"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-3-omschrijving"
                        },{
                            "field":"Voorraad3"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-3-voorraad"
                        },{
                            "field":"Prijs3"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-3-prijs"
                        },{
                            "field":"Bestelnummer3"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-3-bestelnummer"
                        }]
                    },{
                        "caption":"Artikelvariant-4"
                        ,"fields": [{
                            "field":"Image4"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving4"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-4-omschrijving"
                        },{
                            "field":"Voorraad4"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-4-voorraad"
                        },{
                            "field":"Prijs4"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-4-prijs"
                        },{
                            "field":"Bestelnummer4"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-4-bestelnummer"
                        }]
                    },{
                        "caption":"Artikelvariant-5"
                        ,"fields": [{
                            "field":"Image5"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving5"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-5-omschrijving"
                        },{
                            "field":"Voorraad5"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-5-voorraad"
                        },{
                            "field":"Prijs5"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-5-prijs"
                        },{
                            "field":"Bestelnummer5"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-5-bestelnummer"
                        }]
                    },{
                        "caption":"Artikelvariant-6"
                        ,"fields": [{
                            "field":"Image6"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"Omschrijving6"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-6-omschrijving"
                        },{
                            "field":"Voorraad6"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-6-voorraad"
                        },{
                            "field":"Prijs6"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-6-prijs"
                        },{
                            "field":"Bestelnummer6"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-6-bestelnummer"
                        }]
                    }]
                },{
                
                	"formname":"Fancy-Extras"
                    ,"formtabs":[{
                        "caption":"Fancy Extras"
                        ,"fields": [{
                            "field":"xdoel"
                            ,"inputTV":"hiddenTV"
                        }]
                    },{
                        "caption":"Item-1"
                        ,"fields": [{
                            "field":"xImage1"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving1"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-1-omschrijving"
                        },{
                            "field":"xVoorraad1"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-1-voorraad"
                        },{
                            "field":"xPrijs1"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-1-prijs"
                        },{
                            "field":"xBestelnummer1"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-1-bestelnummer"
                        }]
                    },{
                        "caption":"Item-2"
                        ,"fields": [{
                            "field":"xImage2"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving2"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-2-omschrijving"
                        },{
                            "field":"xVoorraad2"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-2-voorraad"
                        },{
                            "field":"xPrijs2"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-2-prijs"
                        },{
                            "field":"xBestelnummer2"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-2-bestelnummer"
                        }]
                    },{
                        "caption":"Item-3"
                        ,"fields": [{
                            "field":"xImage3"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving3"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-3-omschrijving"
                        },{
                            "field":"xVoorraad3"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-3-voorraad"
                        },{
                            "field":"xPrijs3"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-3-prijs"
                        },{
                            "field":"xBestelnummer3"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-3-bestelnummer"
                        }]
                    },{
                        "caption":"Item-4"
                        ,"fields": [{
                            "field":"xImage4"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving4"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-4-omschrijving"
                        },{
                            "field":"xVoorraad4"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-4-voorraad"
                        },{
                            "field":"xPrijs4"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-4-prijs"
                        },{
                            "field":"xBestelnummer4"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-4-bestelnummer"
                        }]
                    },{
                        "caption":"Item-5"
                        ,"fields": [{
                            "field":"xImage5"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving5"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-5-omschrijving"
                        },{
                            "field":"xVoorraad5"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-5-voorraad"
                        },{
                            "field":"xPrijs5"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-5-prijs"
                        },{
                            "field":"xBestelnummer5"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-5-bestelnummer"
                        }]
                    },{
                        "caption":"Item-6"
                        ,"fields": [{
                            "field":"xImage6"
                            ,"caption":"Image"
                            ,"inputTV":"Productimage"
                        },{
                            "field":"xOmschrijving6"
                            ,"caption":"Omschrijving"
                            ,"inputTV":"Artikelvariant-6-omschrijving"
                        },{
                            "field":"xVoorraad6"
                            ,"caption":"Voorraad"
                            ,"inputTV":"Artikelvariant-6-voorraad"
                        },{
                            "field":"xPrijs6"
                            ,"caption":"Prijs"
                            ,"inputTV":"Artikelvariant-6-prijs"
                        },{
                            "field":"xBestelnummer6"
                            ,"caption":"Bestelnummer"
                            ,"inputTV":"Artikelvariant-6-bestelnummer"
                        }]
                    }]
                }]



                here the stored value of one product:

                [{"MIGX_id":"1","MIGX_formname":"Fancy-Opties","doel":"","Image1":"assets\/gallery\/1\/178.jpg","Omschrijving1":"Wenskaart","Voorraad1":954,"Prijs1":"3","Bestelnummer1":"001","Image2":"assets\/gallery\/1\/178.jpg","Omschrijving2":"Gesigneerde gicleeprint 18x18cm","Voorraad2":47,"Prijs2":"40","Bestelnummer2":"001-a","Image3":"assets\/gallery\/1\/178.jpg","Omschrijving3":"Gesigneerde gicleeprint 27x27cm","Voorraad3":19,"Prijs3":"80","Bestelnummer3":"001-b","Image4":"assets\/gallery\/1\/181.jpg","Omschrijving4":"Gesigneerde gicleeprint 27x27cm","Voorraad4":"1000","Prijs4":"50","Bestelnummer4":"001-d","Image5":"","Omschrijving5":"","Voorraad5":"","Prijs5":"","Bestelnummer5":"","Image6":"","Omschrijving6":"","Voorraad6":"","Prijs6":"","Bestelnummer6":""},{"MIGX_id":"2","MIGX_formname":"Fancy-Extras","xdoel":"","xImage1":"","xOmschrijving1":"Lijst voor print 28x28 cm","xVoorraad1":"38","xPrijs1":"40","xBestelnummer1":"lijst voor 18x18","xImage2":"","xOmschrijving2":"Lijst voor print 27x27 cm","xVoorraad2":"39","xPrijs2":"60","xBestelnummer2":"Lijst voor print 27x27 cm","xImage3":"","xOmschrijving3":"","xVoorraad3":"","xPrijs3":"","xBestelnummer3":"","xImage4":"","xOmschrijving4":"","xVoorraad4":"","xPrijs4":"","xBestelnummer4":"","xImage5":"","xOmschrijving5":"","xVoorraad5":"","xPrijs5":"","xBestelnummer5":"","xImage6":"","xOmschrijving6":"","xVoorraad6":"","xPrijs6":"","xBestelnummer6":""}]



                some things are in dutch:
                Prijs=Price
                Omschrijving=discription
                Voorraad=Stock
                Bestelnummer=Productnumber

                In principal a product now can have 6 variantions all with there own valuea's besides that there are 6 extra's possible: for instance Peppers on a Pizza.

                Here you can see the migx products in action.

                http://test.hurby.modxcloud.com/onze-producten/merken/merk-a/product1.html


                Sorting can be limited to the basic price, productnumber and stock of Artikelvariant-1.

                Thnx
                Hurby
                [ed. note: hurby last edited this post 13 years, 11 months ago.]
                  Sommige mensen hebben aan een half woord genoeg
                  • 12491
                  • 90 Posts
                  Hi Bruno did you have any time looking at the problem? I placed the formtabs for you like you asked .

                  Greetings
                  Hurby
                    Sommige mensen hebben aan een half woord genoeg
                    • 4172
                    • 5,888 Posts
                    you can not sort by fields inside a MIGX-TV. All items are stored into one TV as one string.
                    As soon, as you need sorting, filtering over multiple resources and its MIGX-items you will be better by using custom-tables to store your records and using MIGXdb to manage them.
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!