Image block template

Permalink 1 user found helpful
I tried to add a second template to the image block which is usually quite easy, especially for such a simple block.

In this case however, I've got a little problem. view.php contains just one call to getContentAndGenerate() and that's it.

This makes it a lot more complicated. Is there a reason why the controller writes all the layout stuff?

Would you consider changing it if I would send you a patch that replaces getContentAndGenerate?

Remo
 
ScottC replied on at Permalink Reply
ScottC
I used to use some Andrew code for this, and I have abstracted it back into the controller, but sometimes it is easier to do in the view.

Since the imageblock uses the libraryfile block, it is very easy to determine paths with the built in methods.
$fileobject = $controller->getFileObject();  //I believe this is fID  echo($fileobject->getFileRelativePath()); //relative path of a given fID

that will get the path to your image, you can build a little image tag from that no problem :) Especially for a man of your stature.

In the interest of pure views all code like the stuff you mentioned should in my opinion be done back in the controller; the view should simply echo stuff from the controller in placeholders in pure html code.

You can write this in about 8 different ways. I probably have six of them somewhere!

Keep it real.

-Scott
olay replied on at Permalink Reply
olay
Just come across the myself when trying to edit the image block view.php.

Scott – thanks for your note above, however my skills aren't as comprehensive as Remo's (!) any further advice on how to wrap this into a template.

I've tried the following, however the img src is not valid url

<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
$fileobject = $controller->getFileObject();
?>
<div><img src="<?php echo($fileobject->getFileRelativePath()); ?>"/></div>


Thanks