Is it possible to filter entries based on entry table field values?












2














I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.



First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.



Second: I would like to be able to display these values so that they are in an ascending order.










share|improve this question







New contributor




Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    2














    I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.



    First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.



    Second: I would like to be able to display these values so that they are in an ascending order.










    share|improve this question







    New contributor




    Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      2












      2








      2







      I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.



      First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.



      Second: I would like to be able to display these values so that they are in an ascending order.










      share|improve this question







      New contributor




      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.



      First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.



      Second: I would like to be able to display these values so that they are in an ascending order.







      craft3






      share|improve this question







      New contributor




      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 9 hours ago









      Aleks P

      112




      112




      New contributor




      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Aleks P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          2














          OK, one possible way is the use the value of the colour field in an if statement, something this:



          {# list rows that have "blue" in the colour field #}
          {% for row in table.fieldName %}
          {% if row.colour == 'blue' %} // probably best to make "blue" a variable
          <li>{{ row.age }} - {{ row.provider }} - etc.</li>
          {% endif %}


          In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit



          You could also do it with JavaScript, but that is nasty.



          Here is the complete code using an Array to sort by the age field:



          {% set tableBlock =  %}
          {% set tableRow = %}

          {% for row in entry.myTableField %}
          {% if row.colour == "blue" %}

          {% set tableRow = {
          'age' : row.age,
          'colour' : row.colour,
          'provider' : row.provider
          } %}
          {% set tableBlock = tableBlock|merge([tableRow]) %}
          {% endif %}

          {% endfor %}

          {% for row in tableBlock|sort %}
        • {{row.age}} {{row.colour}} {{row.provider}}

        • {% endfor %}


          For some reason the code block formatting is not working...






          share|improve this answer































            0














            I think you will need to be more specific, perhaps give a code example?






            share|improve this answer





















            • @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
              – Aleks P
              7 hours ago













            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "563"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Aleks P is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcraftcms.stackexchange.com%2fquestions%2f28976%2fis-it-possible-to-filter-entries-based-on-entry-table-field-values%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            OK, one possible way is the use the value of the colour field in an if statement, something this:



            {# list rows that have "blue" in the colour field #}
            {% for row in table.fieldName %}
            {% if row.colour == 'blue' %} // probably best to make "blue" a variable
            <li>{{ row.age }} - {{ row.provider }} - etc.</li>
            {% endif %}


            In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit



            You could also do it with JavaScript, but that is nasty.



            Here is the complete code using an Array to sort by the age field:



            {% set tableBlock =  %}
            {% set tableRow = %}

            {% for row in entry.myTableField %}
            {% if row.colour == "blue" %}

            {% set tableRow = {
            'age' : row.age,
            'colour' : row.colour,
            'provider' : row.provider
            } %}
            {% set tableBlock = tableBlock|merge([tableRow]) %}
            {% endif %}

            {% endfor %}

            {% for row in tableBlock|sort %}
          • {{row.age}} {{row.colour}} {{row.provider}}

          • {% endfor %}


            For some reason the code block formatting is not working...






            share|improve this answer




























              2














              OK, one possible way is the use the value of the colour field in an if statement, something this:



              {# list rows that have "blue" in the colour field #}
              {% for row in table.fieldName %}
              {% if row.colour == 'blue' %} // probably best to make "blue" a variable
              <li>{{ row.age }} - {{ row.provider }} - etc.</li>
              {% endif %}


              In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit



              You could also do it with JavaScript, but that is nasty.



              Here is the complete code using an Array to sort by the age field:



              {% set tableBlock =  %}
              {% set tableRow = %}

              {% for row in entry.myTableField %}
              {% if row.colour == "blue" %}

              {% set tableRow = {
              'age' : row.age,
              'colour' : row.colour,
              'provider' : row.provider
              } %}
              {% set tableBlock = tableBlock|merge([tableRow]) %}
              {% endif %}

              {% endfor %}

              {% for row in tableBlock|sort %}
            • {{row.age}} {{row.colour}} {{row.provider}}

            • {% endfor %}


              For some reason the code block formatting is not working...






              share|improve this answer


























                2












                2








                2






                OK, one possible way is the use the value of the colour field in an if statement, something this:



                {# list rows that have "blue" in the colour field #}
                {% for row in table.fieldName %}
                {% if row.colour == 'blue' %} // probably best to make "blue" a variable
                <li>{{ row.age }} - {{ row.provider }} - etc.</li>
                {% endif %}


                In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit



                You could also do it with JavaScript, but that is nasty.



                Here is the complete code using an Array to sort by the age field:



                {% set tableBlock =  %}
                {% set tableRow = %}

                {% for row in entry.myTableField %}
                {% if row.colour == "blue" %}

                {% set tableRow = {
                'age' : row.age,
                'colour' : row.colour,
                'provider' : row.provider
                } %}
                {% set tableBlock = tableBlock|merge([tableRow]) %}
                {% endif %}

                {% endfor %}

                {% for row in tableBlock|sort %}
              • {{row.age}} {{row.colour}} {{row.provider}}

              • {% endfor %}


                For some reason the code block formatting is not working...






                share|improve this answer














                OK, one possible way is the use the value of the colour field in an if statement, something this:



                {# list rows that have "blue" in the colour field #}
                {% for row in table.fieldName %}
                {% if row.colour == 'blue' %} // probably best to make "blue" a variable
                <li>{{ row.age }} - {{ row.provider }} - etc.</li>
                {% endif %}


                In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit



                You could also do it with JavaScript, but that is nasty.



                Here is the complete code using an Array to sort by the age field:



                {% set tableBlock =  %}
                {% set tableRow = %}

                {% for row in entry.myTableField %}
                {% if row.colour == "blue" %}

                {% set tableRow = {
                'age' : row.age,
                'colour' : row.colour,
                'provider' : row.provider
                } %}
                {% set tableBlock = tableBlock|merge([tableRow]) %}
                {% endif %}

                {% endfor %}

                {% for row in tableBlock|sort %}
              • {{row.age}} {{row.colour}} {{row.provider}}

              • {% endfor %}


                For some reason the code block formatting is not working...







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 6 hours ago

























                answered 7 hours ago









                Roi Agneta

                6762616




                6762616























                    0














                    I think you will need to be more specific, perhaps give a code example?






                    share|improve this answer





















                    • @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                      – Aleks P
                      7 hours ago


















                    0














                    I think you will need to be more specific, perhaps give a code example?






                    share|improve this answer





















                    • @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                      – Aleks P
                      7 hours ago
















                    0












                    0








                    0






                    I think you will need to be more specific, perhaps give a code example?






                    share|improve this answer












                    I think you will need to be more specific, perhaps give a code example?







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 8 hours ago









                    Roi Agneta

                    6762616




                    6762616












                    • @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                      – Aleks P
                      7 hours ago




















                    • @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                      – Aleks P
                      7 hours ago


















                    @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                    – Aleks P
                    7 hours ago






                    @RoiAgenta My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style". As per my first question I would like to display all review entries with the colour = "blue" in one listing. For the second question I would like to display all review entires in ascending order according to their age value.
                    – Aleks P
                    7 hours ago












                    Aleks P is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Aleks P is a new contributor. Be nice, and check out our Code of Conduct.













                    Aleks P is a new contributor. Be nice, and check out our Code of Conduct.












                    Aleks P is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Craft CMS Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcraftcms.stackexchange.com%2fquestions%2f28976%2fis-it-possible-to-filter-entries-based-on-entry-table-field-values%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Eastern Orthodox Church

                    Zagreb

                    Understanding the information contained in the Deep Space Network XML data?