Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I need to position some items based on a field value e.g. checkbox is enabled
How can I filter one content types with a specific taxonomy term and with these checkbox enabled?
Comment | File | Size | Author |
---|---|---|---|
#16 | menu_position-field-value-1987108-16.patch | 6.75 KB | skylord |
#15 | menu_position-field-value-1987108-15.patch | 6.82 KB | skylord |
#13 | menu_position-field-value-1987108-13.patch | 1.51 KB | focal55 |
#9 | menu_position-field-value-1987108-9.patch | 6.25 KB | mstrelan |
#5 | menu_position-field-value-1987108-5.patch | 5.96 KB | Agileware |
Comments
Comment #1
mike.davis CreditAttribution: mike.davis commentedHi @hass,
I have recently had the need to also add a condition based upon a field name value., here is a patch that has worked for me.
This currently just provides a list of fields that are available in the site and a text field for the value to match against. This currently only works for node data, but it probably wouldn't be a big change to make it work with taxonomy as well.
Thanks
Mike
Comment #2
mike.davis CreditAttribution: mike.davis commentedForgot to mark it for review.
Comment #3
mike.davis CreditAttribution: mike.davis commentedarh ... wrong status .. sorry :)
Comment #4
rvilarIt works for me.
Comment #5
Agileware CreditAttribution: Agileware commentedUpdated patch to #1 which fixes a problem where Entity Reference field values were not being compared.
Comment #6
axe312 CreditAttribution: axe312 commentedPatch is working very well with list fields. Haven't testet it yet with entity reference fields.
Comment #7
Leksat CreditAttribution: Leksat commentedI did not look at the code, but can confirm that #5 patch works well with common fields.
Comment #8
kreatIL CreditAttribution: kreatIL commentedPatch #5 works for me. In my use case I'm checking against a multi-value entity reference field which references taxonomy terms. Therefore I had to add a new line after line 24:
in order to retrieve the name value of delta#0 for that field.
I'm sure there would be a more flexible solution for that, but in my special use case it works perfectly.
Comment #9
mstrelan CreditAttribution: mstrelan commentedPatch #5 does not work for multi-value fields, eg select lists. Also updated
if
statements to use Drupal coding standards and use ofdrupal_map_assoc()
instead ofarray_combine()
.Comment #10
rv0 CreditAttribution: rv0 commentedThanks for this patch, works very well!!
Comment #11
cdmo CreditAttribution: cdmo commented#9 worked for me on a select list. I applied the patch to 7.x-1.2
Thanks!
Comment #12
BarisW CreditAttribution: BarisW at LimoenGroen for Gemeente Venlo commentedWhat is this 'identifier' => 'TRUE'? I've never seen it. What's its use?
This should be
'#empty_option' => t('- Please select -'),
on the select. Mind the t().
Other than that, the patch looks good. Please re-roll against dev.
Comment #13
focal55 CreditAttribution: focal55 commentedNew patch re-rolled against 7.x-2.x that addresses BarisW's second point.
Comment #14
BarisW CreditAttribution: BarisW at LimoenGroen for Gemeente Venlo commentedThanks all, but the patch in #13 is missing the newly added file from #9.
If someone can combine these changes into one patch, that would be nice.
Comment #15
skylord CreditAttribution: skylord commented#9 with fix from #13
Comment #16
skylord CreditAttribution: skylord commented#13 was buggy as i see now. :-) So, here's fixed patch which one also addresses #12