Hi,
Thank you for reply.
Actually when I tried, I am getting error as call to member function getInstance() on null.
I can't find out the way to rectify it.
I have added my file here.
If i could get instance_id I can get banner_list.
Sorry I can't understand hook concept and how to use it.
class ControllerApiCommonBlocksBannerBlock extends AControllerAPI {
protected $registry;
public function onControllerBlocksBannerBlock_InitData()
{
$this->registry = Registry::getInstance();
$instance_id = $this->baseObject->getInstance();
//var_dump($instance_id);
}
public function get() {
$this->extensions->hk_InitData($this,__FUNCTION__);
$request = $this->rest->getRequestParams();
$controller="pages/index/home";
$this->layout->buildPageData($controller);
$instance_id=""; //have to get through hooking
$response=$this->getBlockContent($instance_id);
$this->extensions->hk_UpdateData($this,__FUNCTION__);
$this->rest->setResponseData( $response );
$this->rest->sendResponse( 200 );
}
public function getBlockContent($instance_id) {
$block_info = $this->layout->getBlockDetails($instance_id);
$custom_block_id = $block_info['custom_block_id'];
$this->loadModel('extension/banner_manager');
$results = $this->model_extension_banner_manager->getBanners($custom_block_id);
$banners = array();
if($results){
$rl = new AResource('image');
foreach($results as $row){
if($row['banner_type']==1){ // if graphic type
/**
* @var array
*/
$row['images'] = $rl->getResourceAllObjects('banners',$row['banner_id']);
//add click registration wrapper to each URL
//NOTE: You can remove below line to use tracking javascript instead. Javascript tracks HTML banner clicks
$row['target_url'] = $this->html->getURL('r/extension/banner_manager/click', '&banner_id='.$row['banner_id'], true);
} else {
$row['description'] = html_entity_decode($row['description']);
}
$banners[] = $row;
}
}
$output = array(
'content' => $banners
);
return $output;
}
}