I am using the [node:group_audience] token in custom breadcrumbs and the [node:group_audience] is rendering with HTML hyperlink markup:
Home » <a href="/drupal-7.8/?q=administration">Administration</a> » Administration Wiki

Comments

bulldozer2003’s picture

Project: Organic groups » Token
Version: 7.x-1.1 » 7.x-1.0-beta6
Component: og.module » Code

Anyone know where I can fix this token replacement to not add the markup as part of the replacement?

I'm moving this because I've gotten no traction in OG (where I guess the token is defined).

Dave Reid’s picture

Status: Active » Fixed

I just created a doc page on customizing how field tokens are output:
http://drupal.org/node/1299662

You may also want to point the og maintainers to http://drupal.org/node/1252608 on how to provide a sane default formatter for their field types.

bulldozer2003’s picture

Status: Fixed » Active

Thank you for the information! It looks like OG only offers one formatter :( I will look up how to define a new plain text formatter and submit it to OG as a patch.
The current formatter providing links should probably left as default. How would I define which formatter Tokens is supposed to use?

Dave Reid’s picture

Title: group_audience token being rendered with HTML markup » Provide a plain text formatter for the group_audience field that can be used with tokens
Project: Token » Organic groups
Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Component: Code » og.module
Category: bug » task

How would I define which formatter Tokens is supposed to use?

This is covered by http://drupal.org/node/1252608 :) Transferring this issue back to OG.

bulldozer2003’s picture

I've added the default_token_formatter to the og_field_info function (see below) in my site's og.field.inc file but "Group default list" is still the only formatter available to the Group Audience field. I also tried deleting the field and re-adding it.

 function og_field_info() {
   return array(
     'group' => array(
       'label' => t('Group audience'),
       'description' => t('This field stores groups associated with the content.'),
       'default_widget' => OG_AUDIENCE_WIDGET,
       'default_formatter' => 'og_list_default',
+      'default_token_formatter' => 'taxonomy_term_reference_plain',
       // We do not expose the field as entity property, but we provide a
       // separate property making use of the membership entities instead.
     ),
   );
 }
amitaibu’s picture

Status: Active » Closed (won't fix)

I think there are better ways to form a breadcrumb instead of using the field itself -- just using it's token, but anyway this formatter can be done in a custom module, it's out of the scope for OG itself.

bulldozer2003’s picture

Status: Closed (won't fix) » Active

Do you have any suggestions of better ways to form a breadcrumb?
And doesn't OG provide the token definitions that Token can use?

bulldozer2003’s picture

Project: Organic groups » Token
Version: 7.x-1.x-dev » 7.x-1.0-beta6
Component: og.module » Miscellaneous
Category: task » support

No traction with OG :-( I'm back to ask about the change I made to og_field_info if you see comment #5. Does the 'default_token_formatter' need to be defined anywhere else?

bulldozer2003’s picture

Oh, I think I see the problem, I'm using 'taxonomy_term_reference_plain' in OG... I guess I do need to define a new plain formatter in OG?

ohthehugemanatee’s picture

Seconding the problem here. What are some alternative approaches to generating the breadcrumb, or to generating the token? Amitaibu, is it normal for a token to include HTML? If we throw together a plaintext formatter for group, can we get it included in the module as the default display formatter for this field in token form?

bulldozer2003: the latest dev of custom_breadcrumbs supports using raw PHP to generate an array that will be used as your breadcrumb. So we could use a PHP snippet to get around this token issue.

An alternate approach would be to improve custom_breadcrumb with an option to remove HTML from breadcrumb title elements. Hard to think of a use case where you would want it displayed, really...

ohthehugemanatee’s picture

Issue summary: View changes

Put text in code as HTML was being rendered.