How do you extend block capability to include thumbnails?
Permalink 1 user found helpful
I've had good luck so far writing (adapting, actually) my own simple blocks, but they've been limited to written information. Things like "name, price, description" in a restaurant menu.
But how do you add the capability to include a thumbnail image? So you would have instead, for instance, "name, price, thumbnail (clickable, so it pops up a larger view), description."
But how do you add the capability to include a thumbnail image? So you would have instead, for instance, "name, price, thumbnail (clickable, so it pops up a larger view), description."
I downloaded it. I installed it. I used it. Then I posted a 5-star review. Holy crap, this thing is sweet.
:) I know Jordanlev has good Karma ... maybe you can help my karma by marking my answer the best
... update ... I meant my answer with the code examples and explanation, grins ... oh well at least I got karma yay!!!!
... update ... I meant my answer with the code examples and explanation, grins ... oh well at least I got karma yay!!!!
I may have good karma, but I don't have a sales team -- until now!
Thanks for the great explanation and sharing your own code. Have some karma :)
Thanks for the great explanation and sharing your own code. Have some karma :)
http://www.concrete5.org/marketplace/addons/designer-content/...
This FREE block will do everything you want... plus, once you build your custom block with it take a look at the newly created block code to see how it does it. Really awesome way to learn about custom blocks.
For quick and dirty code:
Here's n example of code I've used for my blocks view file:
Depending on your block you may retrieve images from either the file manager by ID, which is saved in the blocks db.xml file or you design your block to display images that are stored in custom page attributes e.g. a blog roll with thumbnails.
For a block that has an image attribute for selecting an image on a per block basis you should really take a look at the Designer Content block, it will do everything you want and when you're finished just learn from the generated source code.
For a block that displays an image that is stored in a custom page attribute I can give you a recent example I've used to retrieve images from custom page attributes and display them on the page.
There's a bit more to it than that, like setting up your block edit form & db.xml file (don't forget to refresh database tables after change under 'Add Functionality' in dashboard).
I've seen many different ways to do it so once you get the basics you'll find that it's very flexible.
Cheers,
Aaron