Opened 18 years ago

Closed 18 years ago

Last modified 7 years ago

#2800 closed enhancement (fixed)

[patch] Make ifchanged tag accept a parameter

Reported by: wolfram@… Owned by: Adrian Holovaty
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The patch allows to pass a parameter to ifchanged, which is then evaluated and checked if it has changed, instead of the tag’s content. If it has changed the content is being printed, as usual. I.e. you can do

{% ifchanged variable %}print if variable's value has changed{% ifchanged %}

To know more about the details, read here.

Attachments (3)

enhanced-ifchanged.patch (2.5 KB ) - added by anonymous 18 years ago.
ifchanged-tests.patch (1.4 KB ) - added by anonymous 18 years ago.
ifchanged-multi-parameters.patch (6.2 KB ) - added by anonymous 18 years ago.

Download all attachments as: .zip

Change History (9)

by anonymous, 18 years ago

Attachment: enhanced-ifchanged.patch added

comment:1 by Wolfram Kriesing, 18 years ago

A little more explaination may be. In my case I had nested for loops and wanted to check if the outer had changed and modify something inside the inner loop.
That was impossible using ifchanged without telling what to look for if it had changed, so I enhanced ifchanged's syntax.
I hope you find it useful too.
Having ifchanged accept a parameter would be phantastic. Like so:

{% for country in countries %}
    {% for city in country.cities %}
        <div class="city{% ifchanged country %}Alternate{% endifchanged %}">
            {{ city.name }}
        </div>
    {% endfor %}
{% endfor %}

The ifchanged tag should be able to check if a certain variable has changed if given, otherwise work as usual.

by anonymous, 18 years ago

Attachment: ifchanged-tests.patch added

comment:2 by anonymous, 18 years ago

Summary: Make ifchanged tag accept a parameter[patch] Make ifchanged tag accept a parameter

comment:3 by wolfram.kriesing@…, 18 years ago

The following updated patch allows for multiple parameters, such as:

{% ifchanged date.hour,date.date %}

Examples, doc and tests included.

by anonymous, 18 years ago

comment:4 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

(In [4050]) Fixed #2800: the ifchanged tag now can optionally take paramaters to be checked for changing (instead of always using the content). Thanks, Wolfram Kriesing.

Note: See TracTickets for help on using tickets.
Back to Top