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.
When I add "Node: Sticky" to a view, it has a dropdown for "Output format" that is Yes/No, True/False, On/Off. I would like one more that is "Sticky: / " so that it will print "Sticky:" (translated, preferably) if the node is sticky and nothing otherwise. This can be used for labeling along with the title when you have a list of titles.
Marking this as DruBB since I'm specifically wanting it for the forum topic list, but I think it has wider uses as well.
Michelle
Comment | File | Size | Author |
---|---|---|---|
#12 | views-496840_0_0_0.patch | 5.11 KB | merlinofchaos |
#11 | views-496840_0_0.patch | 3.57 KB | dawehner |
#9 | views-496840_0.patch | 3.01 KB | dawehner |
#7 | views-496840.patch | 2.67 KB | dawehner |
#1 | views-496840.patch | 2.26 KB | dawehner |
Comments
Comment #1
dawehnerneeds review :)
Perhaps there should be a easier mechanism to extends fields for things like this.
Comment #2
MichelleHey, thanks. Earl said to just put it in the style so that's what I did but I will give this a shot and see if it works better. That will make it more flexible for folks as well to decice if they want the sticky label there or not.
Michelle
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI would rather modify the boolean handler so that fields can add custom variations without writing new handlers.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedComment #5
dawehnerI'm wondering myself how this can be achived
I guess it could be done in the hook_views_data definition
Perhaps with a additional parameter here, i see i have to read more in views.
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedYeah. It'd be something like 'output formats' => array('sticky' => array('', t('Sticky'))
Or something.
Comment #7
dawehneryeah, thats much more flexible
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedThis patch looks good. 'output formats' needs to be documented in the header of the class, since that's the only place to find documentation for what's available in the definitions.
Comment #9
dawehnerUpdate
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedFor documenting definition keys, I usually use doxygen's list formatting capabilities, so each item should have a - in front of it. Since you've got an array embedded, it probably also needs @code and @endcode tags.
Comment #11
dawehnerHere is a patch which uses the codestyle of definitions. I'm not sure about the array
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedDoesn't seem to apply to 7.x, but applied to both 6.x branches.
Actual patch applied attached.
Comment #13
dawehnerThanks for making the patch ready... now i will be able to use this syntax somewhere else .
I commited the patch to d7.
Comment #15
dawehnerThis is now really commited.
Comment #16
mastoll CreditAttribution: mastoll commentedI like this option for Node:sticky. How would one apply it to Node:published as well?