Are there any text field formatters already available anywhere? I guess the most obvious need being a "link to content" formatter?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Scott J’s picture

Or are you planning to add formatter options to this module?

plach’s picture

Category: support » feature

Well, at the moment we are using textfields which do not provide such a formatter, however we could introduce a new one.

Scott J’s picture

Thanks,
I did find an old D5 module called Text Field Tags that provides just what we need I think.

For text fields, you'll find several new options for how the fields are rendered in teasers and full nodes: headings 1 through 4, italics, bold, underline, and block quote (indented).

toxiclung’s picture

subscribe

BrightBold’s picture

subscribe

ohnobinki’s picture

sub

prr2112’s picture

subscribe

5keptic’s picture

subscribed

good_man’s picture

Andreas Radloff’s picture

Status: Active » Needs review
FileSize
4.55 KB

Patch against alpha3 attached that implements a field formater for linking, wrapping in a h*-tag and setting a class.

Status: Needs review » Needs work

The last submitted patch, title-formatters-1062814-10.patch, failed testing.

Andreas Radloff’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha3
FileSize
4.55 KB
Andreas Radloff’s picture

Status: Needs work » Needs review
FileSize
4.55 KB
pyrello’s picture

#13 appears to work. I would suggest that you have an option for -None- under the wrap tag. Also when you don't actually select an option for wrap tag, it outputs < class=""></> around the title.

plach’s picture

#13: title-formatters-1062814-10.patch queued for re-testing.

plach’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.x-dev
Status: Needs review » Needs work

Needs work per #14. Also there are some coding standard issues:

+++ b/title.field.inc
@@ -0,0 +1,156 @@
+  $settings = $display['settings']; // get the settings
+
+  foreach ($items as $delta => $item) {
+    $output = $item['safe_value']; // Getting the actual value
+  }
+

Iniline comments should start with a capital letter and end with a trailing dot. The should have their own line, also.

+++ b/title.field.inc
@@ -0,0 +1,156 @@
+ * Validate that a space-separated list of values are lowercase and appropriate
+ * for use as HTML classes.

This should be one single line or be preceded by a single-line summary, in which case an empty line should separate them.

+++ b/title.field.inc
@@ -0,0 +1,156 @@
+  }
+}
\ No newline at end of file

Missing empty line here.

lathan’s picture

This patch resolves all issues above

lathan’s picture

Status: Needs work » Needs review

status change.

pyrello’s picture

@jucallme - This patch did work for me and fixes the issues above. There are a couple more tiny issues that you may want to fix prior to committing, however.

  • In the wrapper tag option list, -None- is listed after DIV. I would suggest that you either put -None- at the top of the list and default to it, or put it at the bottom of the list if you are going to continue to default to DIV. Personally, I am a fan of less markup, when possible, and Drupal is already very markup heavy. So, for me, I generally prefer modules that set defaults towards less markup.
  • In the field display summary view, it shows that DIV is selected even when I actually selected -None-.

Thanks for your work on this!

plach’s picture

It would be nice to have also the wrapped Title without link if it does not imply too much work.

lathan’s picture

Issues fixed, @plach you would select "Nothing" under title link to for what you are after.

plach’s picture

Cool, I'll review this ASAP :)

plach’s picture

Status: Needs review » Fixed
Issue tags: +Needs tests
FileSize
4.27 KB

Awesome work everybody! I tested this for a while and looks good to go to me. I performed some minor adjustment to the patch, mainly cosmetic stuff (see the attached interdiff). The most relevant change is the following:

-  $element = array();
-
-  $settings = $display['settings']; // Get the settings
-
-  foreach ($items as $delta => $item) {
-    $output = $item['safe_value']; // Getting the actual value
-  }
+  $settings = $display['settings'];
+  $output = isset($items[0]) ? $items[0]['safe_value'] : '';
 
-  if ($settings['title_link'] == 'content') {
+  if (!empty($output) && $settings['title_link'] == 'content') {
     $uri = entity_uri($entity_type, $entity);
-    $output = l(strip_tags($item['value']), $uri['path']);
+    $output = l($output, $uri['path'], array('html' => TRUE));
   }

Basically since here (and also in other places in the Title code) we are assuming that the field has cardinality 1, we should pick the first value, not the last one. Morover I dropped the strip tags approach since we will probably allow for HTML in titles in the future.

Sorry for the long delay, committed and pushed!

Would be good to get some test coverage for this sooner or later, hence marking accordingly.

zennermp’s picture

The search results display mode does not show the title as a link or give it a class (if specified)

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

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

  • Commit ef3d5a1 on 7.x-1.x, workbench authored by Andreas Radloff, committed by plach:
    Issue #1062814 by Andreas Radloff, jucallme, plach | Scott J: Added...