Displaying images' custom attributes?
Permalink Browser Info Environment
Hi Jordan
I've tweaked your block a little to meet my needs (showing images' titles as text next to them), but I'm stumped when trying to display custom attributes. I've created one called 'url' (so each image can have a website associated with it) but I can't grab the attribute URL and display it.
I've tried variations of
in controller.php at around line 57, but it always says getAttributeValue can't be called on a non-object.
Can you help? I know this is a free addon and you must have limited time, but I don't need the functionality of your other image addons so this seemed like a more elegant solution for me.
Thanks!
I've tweaked your block a little to meet my needs (showing images' titles as text next to them), but I'm stumped when trying to display custom attributes. I've created one called 'url' (so each image can have a website associated with it) but I can't grab the attribute URL and display it.
I've tried variations of
$image['url'] = $file->getAttributeValue('url');
in controller.php at around line 57, but it always says getAttributeValue can't be called on a non-object.
Can you help? I know this is a free addon and you must have limited time, but I don't need the functionality of your other image addons so this seemed like a more elegant solution for me.
Thanks!
Type: | Discussion |
---|---|
Status: | New |
Hi Jordan
Thanks for the reply. I didn't post the rest of controller.php because I haven't changed any of it, but anyway, here's the whole thing:
You can see the offending line in the view() function. getAttribute('url') doesn't work, unfortunately.
Here's my custom template, if it helps:
Any help is much appreciated :)
Thanks for the reply. I didn't post the rest of controller.php because I haven't changed any of it, but anyway, here's the whole thing:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); class SimpleImageGalleryBlockController extends BlockController { var $pobj; protected $btDescription = "Displays images in a fileset (with an optional lightbox)."; protected $btName = "Simple Image Gallery"; protected $btTable = 'btSimpleImageGallery'; protected $btInterfaceWidth = "550"; protected $btInterfaceHeight = "175"; public function on_page_view() { if ($this->enableLightbox) { $html = Loader::helper('html'); $bv = new BlockView(); $bv->setBlockObject($this->getBlockObject()); $this->addHeaderItem($html->css($bv->getBlockURL() . '/fancybox/jquery.fancybox-1.3.1.css'));
Viewing 15 lines of 87 lines. View entire code block.
You can see the offending line in the view() function. getAttribute('url') doesn't work, unfortunately.
Here's my custom template, if it helps:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $html = Loader::helper('html'); $column_width = (100 / $displayColumns) . "%"; $rel = "fancybox{$controller->bID}"; //Avoid conflict with other js lightboxes, and isolate each block's prev/next nav to one gallery only. $c = Page::getCurrentPage(); ?> <div class="simple_image_gallery_container"> <?php foreach ($images as $img): ?> <div class="affiliation-entry" style="width: <?php //echo $column_width; ?>;"> <div class="logo" style="height: <?php echo $max_img_height; ?>px;"> <?php echo $html->image($img['thumb_src'], $img['thumb_width'], $img['thumb_height'], array('alt' => $img['title'])); ?> </div> <h2><?php echo $img['title']; ?></h2> <p><?php echo $img['desc']; ?></p>
Viewing 15 lines of 60 lines. View entire code block.
Any help is much appreciated :)
I think you want:
(the "$f" variable is not something specific to Concrete5, just the particular way I have that portion of code coded)
$f->getAttribute('aff_url');
(the "$f" variable is not something specific to Concrete5, just the particular way I have that portion of code coded)
That works great, thanks :)
I sometimes get confused with abstraction in c5... should have seen the line at 35. Oh well, I know now!
I sometimes get confused with abstraction in c5... should have seen the line at 35. Oh well, I know now!
You might also find this helpful:
https://github.com/jordanlev/c5_designer_gallery...