本文整理汇总了PHP中Model_Location::gen_seotitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::gen_seotitle方法的具体用法?PHP Model_Location::gen_seotitle怎么用?PHP Model_Location::gen_seotitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Location
的用法示例。
在下文中一共展示了Model_Location::gen_seotitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_create
/**
* CRUD controller: CREATE
*/
public function action_create()
{
$this->template->title = __('New') . ' ' . __($this->_orm_model);
$this->template->scripts['footer'][] = 'js/gmaps.min.js';
$this->template->scripts['footer'][] = 'js/oc-panel/locations-gmap.js';
$this->template->scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initLocationsGMap';
$location = new Model_Location();
if ($post = $this->request->post()) {
//check if the parent is loaded/exists avoiding errors
$post['id_location_parent'] = $post['id_location_parent'] != '' ? $post['id_location_parent'] : 1;
$parent_loc = new Model_Location($post['id_location_parent']);
if (!$parent_loc->loaded()) {
Alert::set(Alert::INFO, __('You are assigning a parent location that does not exist'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'create')));
}
foreach ($post as $name => $value) {
//for description we accept the HTML as comes...a bit risky but only admin can
if ($name == 'description') {
$location->description = Kohana::$_POST_ORIG['description'];
} elseif ($name != 'submit') {
$location->{$name} = $value;
}
}
if (!isset($post['seoname'])) {
$location->seoname = $location->gen_seotitle($post['seoname']);
} else {
$location->seoname = $post['seoname'];
}
try {
$location->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
$this->action_deep();
Core::delete_cache();
Alert::set(Alert::SUCCESS, __('Location created'));
$this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())) . (Core::post('id_location_parent') ? '?id_location=' . Core::post('id_location_parent') : NULL));
}
$locations = array('' => '');
foreach (Model_Location::get_as_array() as $location) {
$locations[$location['id']] = $location['name'];
}
return $this->render('oc-panel/pages/locations/create', compact('locations'));
}