Simple sidebar block
Permalink 1 user found helpful
Hi - I would like to have a simple block in the sidebar that allowed for uploading an image of certain width 400px and then a title and some copy underneath. It would act as a link to areas within a site....
Is there a good starting template that I can use for this or can someone suggest a way of doing this please?
Is there a good starting template that I can use for this or can someone suggest a way of doing this please?
the image block would be a good start, not sure how i would limit it to 400 px
Could you expand on that and tell me how I would put in a title and some description copy and what file I would need to edit to do this? I can't seem to find a good simple walkthrough to do this amazingly...
Surely expanding the 'Image' block would suit your needs... add an extra field for title and remove any unnecessary ones... hide the max size fields and fix their value to 400px and yer sorted... then adapt the view.php to suit your layout and its done..
Thanks Jimbo could you give me an example of the code please. I would need Title, content and then image. The image would need to float right. I've not done this before so could you tell me how I would apply it to the view.php too. I'd be really gratefull and I'm sure other people would use this...thanks
It's not easy to explain in detail.... it would take several pages...lol..
Leave it with me and I'll try to knock something up for you in the next couple of days.
Leave it with me and I'll try to knock something up for you in the next couple of days.
OK... done... took 30min or so to knock this up... its just a 'bastardised' version of the image block.
The image is the link and the rollover has been removed and it will auto resize the images larger than 400px wide down to 400px wide (height is adjusted accordingly to keep perspective). Note... images less than 400px wide will retain their original size.
This is NOT a package so place the zip contents in your {c5 root}/blocks folder.
Install the block (its called imagePlus)
Edit the view.php to achieve the layout you want.
...and relax... lol
Hope this helps you and anyone else who wants something like this.
The image is the link and the rollover has been removed and it will auto resize the images larger than 400px wide down to 400px wide (height is adjusted accordingly to keep perspective). Note... images less than 400px wide will retain their original size.
This is NOT a package so place the zip contents in your {c5 root}/blocks folder.
Install the block (its called imagePlus)
Edit the view.php to achieve the layout you want.
...and relax... lol
Hope this helps you and anyone else who wants something like this.
Jimbo you're a star - thank you so much for your time on this...
thats ok... where do I send the bill... lol
Hi Jimbo - I wonder if you could help I've been tinkering with your imagePlus block that you did. I have a need for the description to be non-truncated. Is there a way of doing this? I can't seem to find the correct piece of code...I'd be really grateful if you could point me in the right direction...many thanks
How is the description getting truncated? Can you post a screenshot of what you're referring to?
http://www.redback-client.net/blb-pi/index.php/the-team/
Here is a link to the test site the staff biog is being truncated and I can't see where to change that...
Here is a link to the test site the staff biog is being truncated and I can't see where to change that...
I don't see what you're referring to -- can you take a screenshot and circle it or put in an arrow pointing to it or something?
Ther is a whole load of copy that is missing that is in the description field. I think it is expecting to go to a detail area..
Oh, I see. So what's happening is that the "Alt Text" field is limited to 255 characters in the database.
What you want to do is edit the "db.xml" file, find this line:
and change it to this:
That tells the database to NOT limit the field to 255 characters but instead make it unlimited in length.
You're going to need to do 2 things to activate this change, though:
1) Apply this schema change to the database (you just changed it in the file -- but you need to tell the system to look at the file and do that to the actual database itself). Do this by going to the Dashboard -> Add Functionality, clicking the "Edit" button next to this block, then click the "Refresh" button.
2) You're going to need to re-enter the full text for each of those images, because it has only stored the truncated text (it's not actually truncating them when it displays them, but rather it truncated them when you originally saved them so the rest of the text is not in the system anywhere).
One more thing -- you probably want to also change this line in the block's controller.php file:
to this:
(I just changed the "$this->altText" to "$this->altTitle") -- otherwise your extremely long texts are going to go into the alt tag of the image, which should really be shorter (like the title).
-Jordan
What you want to do is edit the "db.xml" file, find this line:
<field name="altText" type="C" size="255">
and change it to this:
<field name="altText" type="X">
That tells the database to NOT limit the field to 255 characters but instead make it unlimited in length.
You're going to need to do 2 things to activate this change, though:
1) Apply this schema change to the database (you just changed it in the file -- but you need to tell the system to look at the file and do that to the actual database itself). Do this by going to the Dashboard -> Add Functionality, clicking the "Edit" button next to this block, then click the "Refresh" button.
2) You're going to need to re-enter the full text for each of those images, because it has only stored the truncated text (it's not actually truncating them when it displays them, but rather it truncated them when you originally saved them so the rest of the text is not in the system anywhere).
One more thing -- you probably want to also change this line in the block's controller.php file:
$img = "<img border=\"0\" class=\"ccm-image-block\" alt=\"{$this->altText}\" src=\"{$relPath}\" {$sizeStr} ";
to this:
$img = "<img border=\"0\" class=\"ccm-image-block\" alt=\"{$this->altTitle}\" src=\"{$relPath}\" {$sizeStr} ";
(I just changed the "$this->altText" to "$this->altTitle") -- otherwise your extremely long texts are going to go into the alt tag of the image, which should really be shorter (like the title).
-Jordan