Solved

How to add a "contains" filter to web data feed

  • 13 February 2021
  • 1 reply
  • 185 views

Badge +2

Hi, 

How can we add a filter to this web feed to only show items that contains the text string: “pacifier”

 

...

<table>
    <tbody>
        <tr>{% for item in feeds.sutter_populære.selection1|slice:"9" %}
            <td align="center"><a href="{{ item.selection2_url }}"><img src="{{ item.selection2 }}" style="margin-top: 10px; max-height: 120px; width: auto;" /></a>

            <p><a href="{{ item.selection2_url }}" style="font-size:12px;">{{ item.name|truncatechars:40 }}</a></p>

            <p style="font-size: 12px; color: #696969;">DKK {{ item.selection3 }} <span style="text-decoration:line-through; font-size: 10px;">{{ item.selection4 }}</span></p>
            </td>
            {% if forloop.last %}
        </tr>
        {% else %}{% if forloop.counter|divisibleby:"3" %}
        <tr>{% endif %}{% endif %}{% endfor %}
        </tr>
    </tbody>
</table>

...

icon

Best answer by caroline 18 February 2021, 23:57

View original

1 reply

Userlevel 5
Badge +8

Hi there,

The following should work:

<table>
    <tbody>
        <tr>{% for item in feeds.sutter_populære.selection1|slice:"9" %}{% if ‘pacifier’ in item.name %}
            <td align="center"><a href="{{ item.selection2_url }}"><img src="{{ item.selection2 }}" style="margin-top: 10px; max-height: 120px; width: auto;" /></a>

            <p><a href="{{ item.selection2_url }}" style="font-size:12px;">{{ item.name|truncatechars:40 }}</a></p>

            <p style="font-size: 12px; color: #696969;">DKK {{ item.selection3 }} <span style="text-decoration:line-through; font-size: 10px;">{{ item.selection4 }}</span></p>
            </td>
            {% if forloop.last %}
        </tr>
        {% else %}{% if forloop.counter|divisibleby:"3" %}
        <tr>{% endif %}{% endif %}{% endif %}{% endfor %}
        </tr>
    </tbody>
</table>

 

Best,

Caroline

 

Reply