当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentModel::get方法代码示例

本文整理汇总了PHP中ContentModel::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::get方法的具体用法?PHP ContentModel::get怎么用?PHP ContentModel::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentModel的用法示例。


在下文中一共展示了ContentModel::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:34,代码来源:ContentAdminWidget.php

示例2: ModelFactory

//}
$fac = new ModelFactory('BlogArticleModel');
foreach ($fac->get() as $model) {
    /** @var BlogArticleModel $model */
    /** @var PageModel $page */
    $page = $model->getLink('Page');
    $page->setMeta('description', $model->getTeaser());
    $page->setMeta('image', $model->get('image'));
    $page->set('published_status', $model->get('status'));
    $page->set('published', $model->get('published'));
    // Clone this to a content page.
    $content = new ContentModel();
    $content->set('nickname', $model->get('title'));
    $content->set('created', $model->get('created'));
    $content->set('updated', $model->get('updated'));
    $content->save();
    $page->set('component', 'content');
    $page->set('baseurl', '/content/view/' . $content->get('id'));
    $page->set('editurl', '/content/edit/' . $content->get('id'));
    $page->set('deleteurl', '/content/delete/' . $content->get('id'));
    $page->set('page_template', 'blog-article.tpl');
    $page->save();
    $insertable = new InsertableModel();
    $insertable->set('site', $page->get('site'));
    $insertable->set('baseurl', '/content/view/' . $content->get('id'));
    $insertable->set('name', 'body');
    $insertable->set('value', $model->get('body'));
    $insertable->save();
    $model->resetLink('Page');
    $model->delete();
}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:31,代码来源:next_page_updates.php

示例3: delete

 public function delete()
 {
     $view = $this->getView();
     $request = $this->getPageRequest();
     // This is a POST-only page.
     if (!$request->isPost()) {
         return View::ERROR_BADREQUEST;
     }
     if (!$this->setAccess('p:/content/manage_all')) {
         return View::ERROR_ACCESSDENIED;
     }
     $m = new ContentModel($request->getParameter(0));
     $link = \Core\resolve_link($m->get('baseurl'));
     if (!$m->exists()) {
         return View::ERROR_NOTFOUND;
     }
     $m->delete();
     \Core\set_message('Removed ' . $m->get('nickname') . ' successfully!', 'success');
     $hist = $request->getReferrer();
     if ($hist == $link) {
         \Core\redirect('/admin/pages');
     } else {
         \Core\go_back();
     }
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:25,代码来源:ContentController.php


注:本文中的ContentModel::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。