本文整理汇总了PHP中Model_Ad::structured_data方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::structured_data方法的具体用法?PHP Model_Ad::structured_data怎么用?PHP Model_Ad::structured_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Ad
的用法示例。
在下文中一共展示了Model_Ad::structured_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_view
/**
*
* Display single advert.
* @throws HTTP_Exception_404
*
*/
public function action_view()
{
$seotitle = $this->request->param('seotitle', NULL);
if ($seotitle !== NULL) {
$ad = new Model_Ad();
$ad->where('seotitle', '=', $seotitle)->where('status', '!=', Model_Ad::STATUS_SPAM)->limit(1)->cached()->find();
if ($ad->loaded()) {
//throw 404
if ($ad->status == Model_Ad::STATUS_UNAVAILABLE or $ad->status == Model_Ad::STATUS_NOPUBLISHED) {
throw HTTP_Exception::factory(404, __('This advertisement doesn´t exist, or is not yet published!'));
}
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
$location = NULL;
$location_parent = NULL;
if ($ad->location->loaded() and $ad->id_location != 1) {
$location = $ad->location;
//adding the location parent
if ($location->id_location_parent != 1 and $location->parent->loaded()) {
$location_parent = $location->parent;
}
}
$category = NULL;
$category_parent = NULL;
if ($ad->category->loaded()) {
$category = $ad->category;
//adding the category parent
if ($category->id_category_parent != 1 and $category->parent->loaded()) {
$category_parent = $category->parent;
}
}
//base category title
if ($category !== NULL) {
$this->template->title = $category->name;
} else {
$this->template->title = '';
}
//adding location titles and breadcrumbs
if ($location !== NULL) {
$this->template->title .= ' - ' . $location->name;
if ($location_parent !== NULL) {
$this->template->title .= ' (' . $location_parent->name . ')';
Breadcrumbs::add(Breadcrumb::factory()->set_title($location_parent->name)->set_url(Route::url('list', array('location' => $location_parent->seoname))));
}
Breadcrumbs::add(Breadcrumb::factory()->set_title($location->name)->set_url(Route::url('list', array('location' => $location->seoname))));
if ($category_parent !== NULL) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname, 'location' => $location->seoname))));
}
if ($category !== NULL) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname, 'location' => $location->seoname))));
}
} else {
if ($category_parent !== NULL) {
$this->template->title .= ' (' . $category_parent->name . ')';
Breadcrumbs::add(Breadcrumb::factory()->set_title($category_parent->name)->set_url(Route::url('list', array('category' => $category_parent->seoname))));
}
if ($category !== NULL) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($category->name)->set_url(Route::url('list', array('category' => $category->seoname))));
}
}
$this->template->title = $ad->title . ' - ' . $this->template->title;
Breadcrumbs::add(Breadcrumb::factory()->set_title($ad->title));
$this->template->meta_description = $ad->title . ' ' . __('in') . ' ' . $category->name . ' ' . __('on') . ' ' . core::config('general.site_name');
$permission = TRUE;
//permission to add hit to advert and give access rights.
$auth_user = Auth::instance();
if (!$auth_user->logged_in() or $auth_user->get_user()->id_user != $ad->id_user and (!$auth_user->get_user()->is_admin() and !$auth_user->get_user()->is_moderator()) or !$auth_user->get_user()->is_admin() and !$auth_user->get_user()->is_moderator()) {
$permission = FALSE;
$user = NULL;
} else {
$user = $auth_user->get_user()->id_user;
}
Model_Visit::hit_ad($ad->id_ad);
$hits = $ad->count_ad_hit();
$captcha_show = core::config('advertisement.captcha');
if ($ad->get_first_image() !== NULL) {
Controller::$image = $ad->get_first_image();
}
$view_file = 'pages/ad/single';
if (Core::get('amp') == '1') {
$this->template = 'amp/main';
$this->before();
$this->template->canonical = Route::url('ad', array('controller' => 'ad', 'category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
$this->template->structured_data = $ad->structured_data();
$view_file = 'amp/pages/ad/single';
}
$cf_list = $ad->custom_columns();
$this->template->amphtml = Route::url('ad', array('controller' => 'ad', 'category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)) . '?amp=1';
$this->template->bind('content', $content);
$this->template->content = View::factory($view_file, compact('ad', 'permission', 'hits', 'captcha_show', 'user', 'cf_list'));
} else {
//throw 404
throw HTTP_Exception::factory(404, __('Page not found'));
}
} else {
//.........这里部分代码省略.........