You are here

README.txt in Link Badges 7

Link Badges is an API module that allows developers to add iOS-style badges to 
links rendered by theme('link') or the l() function. These are useful for 
things like unread counts. 

Once the module is enabled, badge values can be specified by adding either a 
value or a callback function to the link options array. For example:

Value:
l('Some text', 'some/path', array('link_badge' => array('value' => 10)));

Callback function:
l('Some text', 'some/path', array('link_badge' => array(
                                                    'callback' => 'example_callback_function', 
                                                    'arguments' => array('some_arg' => 'some value', 'another_arg' => 'another_val'),
                                                  )
                                  )
);

The callback function would look like:

function example_callback_function($arguments) {
  $value = get_some_value($arguments['some_arg']);
  if ($value > 0) {
    return $value;
  }
  return NULL;
}

Note: To hide the badge, it's important to pass NULL as the value or return NULL from 
your callback function. Any other return value will be displayed. (including "false" 
values, such as 0) Badges do not have to be numeric. Text will also work.

File

README.txt
View source
  1. Link Badges is an API module that allows developers to add iOS-style badges to
  2. links rendered by theme('link') or the l() function. These are useful for
  3. things like unread counts.
  4. Once the module is enabled, badge values can be specified by adding either a
  5. value or a callback function to the link options array. For example:
  6. Value:
  7. l('Some text', 'some/path', array('link_badge' => array('value' => 10)));
  8. Callback function:
  9. l('Some text', 'some/path', array('link_badge' => array(
  10. 'callback' => 'example_callback_function',
  11. 'arguments' => array('some_arg' => 'some value', 'another_arg' => 'another_val'),
  12. )
  13. )
  14. );
  15. The callback function would look like:
  16. function example_callback_function($arguments) {
  17. $value = get_some_value($arguments['some_arg']);
  18. if ($value > 0) {
  19. return $value;
  20. }
  21. return NULL;
  22. }
  23. Note: To hide the badge, it's important to pass NULL as the value or return NULL from
  24. your callback function. Any other return value will be displayed. (including "false"
  25. values, such as 0) Badges do not have to be numeric. Text will also work.