Can I echo an images description to a block?

Permalink
Hi all,

I am using the Galleria addon and want to have the description from the File Manager echoed below the images.

How do I pull this data from the Db?

Cheers

Ben

bencox
 
jordanlev replied on at Permalink Reply
jordanlev
You want to create a custom template for the Galleria block -- copy packages/asmiller_gallery/blocks/asmiller_gallery/view.php to a new folder:
blocks/asmiller_gallery/templates/

Now rename that new file you just copied to something like "with_titles.php".

Edit that file and find this code:
<?php     
foreach($images as $imgInfo) {
$f = File::getByID($imgInfo['fID']);
echo $imgInfo['width'];
echo '<li><img src="';
echo $f->getRelativePath();
echo '" ';
echo 'title="';
echo $imgInfo['description'];
echo '"/></li>';
;}; ?>

and change it to something like this:
<?php     
foreach($images as $imgInfo) {
$f = File::getByID($imgInfo['fID']);
echo $imgInfo['width'];
echo '<li><img src="';
echo $f->getRelativePath();
echo '" ';
echo 'title="';
echo $imgInfo['description'];
echo '"/>';
echo '<p>'.$imgInfo['description'].'</p>';
echo '</li>';
;}; ?>

(Note that I didn't change much there -- just the last few lines).

Now go to your site and log in. Go to the page with the Galleria block on it, click "Edit Page", then click on the Galleria block and choose "Custom Template" from the popup menu, then select "With Titles" (or whatever you named the custom template file -- as long as you put the copied file in the proper directory it will automatically appear in this list).

This probably won't look exactly the way you want, but hopefully gets you started off in the right direction.

Good luck!

-Jordan
bencox replied on at Permalink Reply
bencox
Jordan,

Thanks for that. I managed to sort it a slightly different way in the end.

Ben