I've got a creative challenge here. I've got a view that creates a grid of images linking to their respective content, but my designer threw in a bit of a twist. He wants me to randomly insert colored squares between every 2-3 images. I was looking into creating a custom template for this view to do the inserting, but he'd also like these colors to be editable through the admin. While there are many ways to accomplish this I'm curious to hear your solutions. I could create a "Grid Color" content type, but I'm not sure I want to clutter my content types with such an obscure type.
-
another approach would be to add a field called color to the respective content.– No SssweatCommented Sep 11, 2015 at 6:42
-
These colors aren't associated with any content. They're spacers to go between the actual content within the result set.– HawkeeCommented Sep 11, 2015 at 13:53
-
now its sounding like custom module to me.– No SssweatCommented Sep 11, 2015 at 22:36
1 Answer
My solution was fairly simple. I created a new content type called "Homepage Grid Spacer" and used auto_nodetitle to suppress the title. I created a single field of the jQuery Colorpicker type and deleted the body. Now the admin can insert these decorative squares between actual flagged content by creating and flagging them in the same fashion.
I updated my view to select the color code and suppress the image field of the actual content and I used the rewrite to add a div with the color in a data field. I couldn't add the field in a style because Drupal doesn't allow this. Then I added a couple lines of JavaScript to take the data color and make that the CSS background color.