Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi!
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.
Comments
Comment #1
valderama CreditAttribution: valderama commentedComment #2
valderama CreditAttribution: valderama commentedComment #3
zengenuity CreditAttribution: zengenuity commentedI 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.
Comment #4
valderama CreditAttribution: valderama commentedHi!
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
Comment #5
zengenuity CreditAttribution: zengenuity commentedOkay, I'll keep an eye on that module.