本文整理匯總了PHP中cmsTemplate::hasOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP cmsTemplate::hasOptions方法的具體用法?PHP cmsTemplate::hasOptions怎麽用?PHP cmsTemplate::hasOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cmsTemplate
的用法示例。
在下文中一共展示了cmsTemplate::hasOptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run($template_name)
{
$template = new cmsTemplate($template_name);
if (!$template->hasOptions()) {
cmsCore::error404();
}
$form = $template->getOptionsForm();
$options = $template->getOptions();
if ($this->request->has('submit')) {
// Парсим форму и получаем поля записи
$options = $form->parse($this->request, true, $options);
// Проверям правильность заполнения
$errors = $form->validate($this, $options);
if (!$errors) {
if ($template->saveOptions($options)) {
cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
} else {
cmsUser::addSessionMessage(LANG_CP_SETTINGS_TPL_NOT_WRITABLE, 'error');
}
$this->redirectToAction('settings');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $this->cms_template->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例2: run
public function run($template_name)
{
$template = new cmsTemplate($template_name);
if (!$template->hasOptions()) {
cmsCore::error404();
}
$form = $template->getOptionsForm();
// Форма отправлена?
$is_submitted = $this->request->has('submit');
$options = $template->getOptions();
if ($is_submitted) {
// Парсим форму и получаем поля записи
$options = $form->parse($this->request, $is_submitted, $options);
// Проверям правильность заполнения
$errors = $form->validate($this, $options);
if (!$errors) {
$template->saveOptions($options);
$this->redirectBack('settings');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}