Great module!

One thing I'm using it for is replacing the node title field with an entity field, giving much greater flexibility of where the title is displayed, and also enabling titles to include a line break.

I can add a H1 tag for the page title and a H2 for teaser title, but need to link the field to it's node and strip out HTML on the teaser.

I'm going to add these two options, would you be interested in including them in the module? Or should I add them via a separate module?

Comments

technikh’s picture

"Strip Out HTML" Yes.
Not sure about linking to node. How are you planning to implement? This is a general purpose field formatter. If you can make it to work/hide for fields of a taxonomy vocabulary or a User profile field then it will make sense.

Please provide the Patch and I will be happy to add to this Module.
Thanks.

technikh’s picture

Added "Link to Node" option in the new dev version.

 	      if($custom_link_to_node && ($context['entity_type'] == 'node')){
 	        $entity_id = $context['entity']->nid;
 	        $path = drupal_get_path_alias("node/$entity_id");
 	        $modified_value = '<a href="/'.$path.'">'.$modified_value.'</a>';
 	      }
robert castelo’s picture

Hi Nikhil,
I've used this for the custom link so it can be used on any entity type:

<?php
  if ($custom_link) {
    $entity_ids = entity_extract_ids($entity_type, $entity);
    $original_value = l($original_value, $entity_type .'/'. $entity_ids[0], array('html' => TRUE));
  }
?> 
robert castelo’s picture

Here's the code for stripping out HTML:

<?php
  if ($custom_html_strip) {
    $original_value = strip_tags($original_value);
  } 
?>
robert castelo’s picture

Would you like a patch for these?

technikh’s picture

Assigned: Unassigned » technikh

Thanks Robert. I will manage without patch.
I guess I will add "preserve tags"(allowable tags) textbox for the strip tags feature.

http://www.w3schools.com/php/func_string_strip_tags.asp

strip_tags(string,allow)

Parameter Description
string Required. Specifies the string to check
allow Optional. Specifies allowable tags. These tags will not be removed

robert castelo’s picture

Nice idea, that gives a lot of flexibility!

technikh’s picture

Status: Active » Fixed

Strip tags feature with option to allow specified tags is committed and released as 7.x-2.0-alpha4
http://drupalcode.org/project/simple_field_formatter.git/commit/2134547

Status: Fixed » Closed (fixed)

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