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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
2.26 KB

needs review :)

Perhaps there should be a easier mechanism to extends fields for things like this.

Michelle’s picture

Hey, 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

merlinofchaos’s picture

I would rather modify the boolean handler so that fields can add custom variations without writing new handlers.

merlinofchaos’s picture

Status: Needs review » Needs work
dawehner’s picture

I'm wondering myself how this can be achived

I guess it could be done in the hook_views_data definition

    'field' => array(
      'handler' => 'views_handler_field_boolean',
      'click sortable' => TRUE,
      //HERE
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_boolean_operator',
      'label' => t('Published'),
      'type' => 'yes-no',
    ),

Perhaps with a additional parameter here, i see i have to read more in views.

merlinofchaos’s picture

Yeah. It'd be something like 'output formats' => array('sticky' => array('', t('Sticky'))

Or something.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.67 KB

yeah, thats much more flexible

merlinofchaos’s picture

Status: Needs review » Needs work

This 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.

dawehner’s picture

Status: Needs work » Needs review
FileSize
3.01 KB

Update

merlinofchaos’s picture

For 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.

dawehner’s picture

FileSize
3.57 KB

Here is a patch which uses the codestyle of definitions. I'm not sure about the array

merlinofchaos’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)
FileSize
5.11 KB

Doesn't seem to apply to 7.x, but applied to both 6.x branches.

Actual patch applied attached.

dawehner’s picture

Status: Patch (to be ported) » Fixed

Thanks for making the patch ready... now i will be able to use this syntax somewhere else .

I commited the patch to d7.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dawehner’s picture

This is now really commited.

mastoll’s picture

I like this option for Node:sticky. How would one apply it to Node:published as well?