I am creating some simple "Formatter" Classes for different field types, to make templating for entities easier. If think it would be great if those formatting classes could be integrated into wrappers_delight.

The basic usage looks like this (eg inside a node--page.tpl.php file):

$page = new PageNodeWrapper($node);

// get the summary or a trimmed version of the body
print $page->formatterBody()->summary(250);

// iterate over all images and print them as thumbnails.
foreach ($page->formatterImages() as $image) {
  print $image->setImageStyle('thumbnail')->img();        

I have played around this afternoon and made a patch with integrated some formatter classes into your wrappers.

It would be great if you think such a features could be integrated in wrappers_delight - otherwise I might go for an own module.

patch.txt9.44 KBvalderama
Members fund testing for the Drupal project. Drupal Association Learn more


valderama’s picture

Issue summary: View changes
valderama’s picture

Issue summary: View changes
zengenuity’s picture

I like this idea a lot. I need some time to review the code and try the system out a bit. I'll try to get to that this weekend and let you know what I think.

valderama’s picture

Status: Active » Postponed


For now I decided to go with a own module. That way I can make it as simple as possible and play around with it quicker.

I use the same concept of generating classes via drush (and have used code from wrappers_delight for that). So basically both modules are similar, but one has a focus on data manipulation / backend code, while the other concentrates on formatting of fields for the frontend. Maybe we find that a merge or deeper integration of both modules might be interesting in the future.

For now I am experimenting over here: https://www.drupal.org/project/entity_formatter

zengenuity’s picture

Okay, I'll keep an eye on that module.