Possibly a feature request

Permalink Browser Info Environment
I have a page attribute that is essentially a thumbnail. I've added this to a block using designer pro. Upon adding the block to a page, I am not presented with the option to select an image for the attribute. Furthermore, when I save the block, I get an error saying "Object of class Concrete\Core\File\File could not be converted to string". Likely I'm doing something wrong but I did think page attributes included thumbnails. Any help would be appreciated. Thanks much.

- Ife

Type: Pre-Sale
Status: Resolved
View Replies:
ramonleenders replied on at Permalink Reply
ramonleenders
Hi there,

Open up the view.php file, in your application/blocks/your_block_handle directory. You will see something like this:

<?php echo Page::getCurrentPage()->getAttribute('thumbnail'); ?>

Change it into this:

<?php echo Page::getCurrentPage()->getAttribute('thumbnail', 'display'); ?>

That will actually display the page attribute, instead of retrieving the raw value (array/object). The image attribute will only display a download link though, so not sure if you'd want that? If not, then you'd have to be doing something else (custom).

What is always the case though, if you select page attribute, is that you DO NOT have to select anything yourself in the block. It will take the attribute assigned to the page. So you will have to select a value for the page. If you simply want to select an image within this very block, select the "Image" field type please! That field got everything you need, resizing, cropping etc. etc.

Kind regards,

Ramon
somesayinice replied on at Permalink Reply
Thanks for the quick reply. What I had been envisioning is that every time the block was added to the page, a user would be prompted to select a file to be associated with the thumbnail attribute. I think I was misunderstanding what the role of the page attribute was. It sounds like it is a way to echo a particular attribute value to the view. Is that correct?
ramonleenders replied on at Permalink Reply
ramonleenders
You are partially right. It should echo the value. Correct. The code though was mssing the "display" part, which is needed for images and other attribute types (I only thought of text). So that's gonna be fixed in the next Block Designer Pro version. Although the "File/Image" attribute will only output a URL with the link to the file. So you will need some custom scripting if you want to output the image.

As for the selecting this every time, that is incorrect. We are talking about a page attribute, and this will not be set using a block. You will have to set page attributes in the "Attributes" section of the page. A block is not meant for that. Block Designer will only let you make use of the "echo'ing" of a specific attribute's value. Usefull if you need the name of the page, the link or a file or whatnot.

If you want to select an image within the block, you can use the "Image" field type of Block Designer. This is a fully featured field type with cropping, resizing, linking etc. etc.

Let me know if you have any more questions!

Kind regards,

Ramon

concrete5 Environment Information

Concrete 5.7

Browser User-Agent String

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.54 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.