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

$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
melat0nin
View Replies: View Best Answer
jordanlev replied on at Permalink Reply
jordanlev
I think it's just "getAttribute" (not "getAttributeValue"). But there might be some other problem elsewhere in your code -- kind of hard to say without seeing it though :)

You might also find this helpful:
https://github.com/jordanlev/c5_designer_gallery...
melat0nin replied on at Permalink Reply
melat0nin
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:

<?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'));


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>


Any help is much appreciated :)
jordanlev replied on at Permalink Best Answer Reply
jordanlev
I think you want:
$f->getAttribute('aff_url');

(the "$f" variable is not something specific to Concrete5, just the particular way I have that portion of code coded)
melat0nin replied on at Permalink Reply
melat0nin
That works great, thanks :)

I sometimes get confused with abstraction in c5... should have seen the line at 35. Oh well, I know now!

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

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

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.