AdSpaceHooks::show_ad_space PHP Method

show_ad_space() public method

显示广告位钩子
public show_ad_space ( array $param )
$param array 钩子相关参数
    public function show_ad_space($param)
    {
        // 获取位置广告信息
        $place = t($param['place']);
        $placeInfo = $this->_getPlaceKey($place);
        $data = $this->model('AdSpace')->getAdSpaceByPlace($placeInfo['id']);
        foreach ($data as &$value) {
            if ($value['display_type'] == 3) {
                $value['content'] = unserialize($value['content']);
                // 获取附件图片地址
                foreach ($value['content'] as &$val) {
                    $attachInfo = model('Attach')->getAttachById($val['banner']);
                    if ($placeInfo['width'] && $placeInfo['height']) {
                        $val['bannerpic'] = getImageUrl($attachInfo['save_path'] . $attachInfo['save_name'], $placeInfo['width'], $placeInfo['height']);
                    } else {
                        $val['bannerpic'] = getImageUrl($attachInfo['save_path'] . $attachInfo['save_name']);
                    }
                }
            }
        }
        $this->assign('data', $data);
        // 设置宽度
        $width = intval($placeInfo['width']);
        $this->assign('width', $width);
        // 设置高度
        $height = intval($placeInfo['height']);
        $this->assign('height', $height);
        // 设置距离顶端距离
        $top = intval($placeInfo['top']);
        $bottom = intval($placeInfo['bottom']);
        $this->assign('top', $top);
        $this->assign('bottom', $bottom);
        //增加自定义广告显示模板功能
        $tpl = $placeInfo['tpl'] ? $placeInfo['tpl'] : 'showAdSpace';
        $this->display($tpl);
    }