Using/referencing a Custom Page Attribute in a package's controller.php

Permalink
I need some expert help with Page Attributes please!

I have a set of pages each with a bunch of thumbnails which I'm using the Lightboxed Image add-on to display as slideshows.

Now I'm trying to slightly modify controller.php for Lightboxed Image so that I can include a page-specific title (ie a Custom Page Attribute) within the caption for the lightboxed image.

So I set up a Custom Page Attribute called slideshow - so far so good.

In controller.php, this is the current code
<?php  
   defined('C5_EXECUTE') or die("Access Denied.");   
   Loader::block('library_file');
   class LightboxedImageBlockController extends BlockController {
      protected $btInterfaceWidth = 300;
      protected $btInterfaceHeight = 450;
      protected $btTable = 'btLightboxedImage';
      public function on_page_view() {
         $co = new Config();
         $pkg = Package::getByHandle("lightboxed_image");
         $co->setPackageObject($pkg);
         $bv = new BlockView();
         $bv->setBlockObject($this->getBlockObject());
         $bt = BlockType::getByHandle($this->btHandle);
         $uh = Loader::helper('concrete/urls');


but in the javascript, this is what I want:

$jstrigger = '<script type="text/javascript"> 
          $(document).ready(function(){
             $("a[rel=\'lb_image\']").colorbox({returnFocus: false, width:"50%", height:"500"}); 
          });
         </script>';
            $("a[rel=\'lb_image\']").colorbox({title:function () {
             return "<b>' . $slidetitle . '</b><br />" + (this.title);
            }});
         $this->addHeaderItem($jstrigger);
      }

where $slidetitle is my page attribute.

Hope this is making sense!
So my question is how would I get the slidetitle Page Attribute in there? I've tried but I just don't know enough about how to code this stuff and I get a fatal error about call to a non-object etc.

thanks a million to anyone who can show me how to do it

prestressed
 
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
You need to grab the page in your controller first.
look here:
http://www.concrete5.org/documentation/introduction/cheat-sheet/...
the you need to get the attribute from that page.
prestressed replied on at Permalink Reply
prestressed
mm, I'm kind of getting there - do you mean I need $c = Page::getCurrentPage(); ?

It works if I put in
$c = Page::getCurrentPage();
$slidetitle = $c->getCollectionAttributeValue('slideshow');


before the javascript section.

Though that same getCurrentPage line does already appear much further down in controller.php, on about line 100. Are there any issues having it in there twice (excuse idiot-question but as you can see my php knowledge is fairly minimal!)