本文整理汇总了PHP中ContentModel::getLink方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::getLink方法的具体用法?PHP ContentModel::getLink怎么用?PHP ContentModel::getLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::getLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: QuickDraftSave
/**
* Form Handler to save a content quick create.
*
* @param Form $form
*
* @return string|bool
*/
public static function QuickDraftSave(Form $form)
{
if (!$form->getElementValue('title')) {
\Core\set_message('All pages must have titles.', 'error');
return false;
}
/** @var $model ContentModel */
$model = new ContentModel();
/** @var $page PageModel Page object for this model, already linked up! */
$page = $model->getLink('Page');
// The content nickname is derived from the page title.
$model->set('nickname', $form->getElementValue('title'));
$model->save();
$ins = new InsertableModel();
$ins->set('site', $page->get('site'));
$ins->set('baseurl', '/content/view/' . $model->get('id'));
$ins->set('name', 'body');
$ins->set('value', '<p>' . nl2br($form->getElementValue('content')) . '</p>');
$ins->save();
$page->set('title', $form->getElementValue('title'));
$page->set('published_status', 'draft');
$page->set('editurl', '/content/edit/' . $model->get('id'));
$page->set('deleteurl', '/content/delete/' . $model->get('id'));
$page->set('component', 'content');
$page->save();
return true;
}
示例2: create
public function create()
{
$view = $this->getView();
$request = $this->getPageRequest();
if (!$this->setAccess('p:/content/manage_all')) {
return View::ERROR_ACCESSDENIED;
}
$model = new ContentModel();
$page = $model->getLink('Page');
//$page = new PageModel('/content/view/new');
// Allow the user to specify a parent URL to default to.
// This is used with the "add page 'here'" option.
if ($request->getParameter('parenturl')) {
$page->set('parenturl', $request->getParameter('parenturl'));
}
if ($request->getParameter('page_template')) {
$page->set('page_template', $request->getParameter('page_template'));
}
$form = new Form();
$form->set('callsmethod', 'ContentController::_SaveHandler');
$form->addModel($page, 'page');
$form->addModel($model, 'model');
// Tack on a submit button
$form->addElement('submit', array('value' => 'Create'));
$view->mastertemplate = 'admin';
$view->templatename = '/pages/content/create.tpl';
$view->title = 'New Content Page';
$view->assignVariable('model', $model);
$view->assignVariable('form', $form);
}