當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContentModel::set方法代碼示例

本文整理匯總了PHP中ContentModel::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentModel::set方法的具體用法?PHP ContentModel::set怎麽用?PHP ContentModel::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ContentModel的用法示例。


在下文中一共展示了ContentModel::set方法的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;
 }
開發者ID:nicholasryan,項目名稱:CorePlus,代碼行數:34,代碼來源:ContentAdminWidget.php

示例2: ModelFactory

//	$model->set('editurl', str_replace('/blog/article/view/', '/blog/article/update/', $model->get('baseurl')));
//	$model->set('deleteurl', str_replace('/blog/article/view/', '/blog/article/delete/', $model->get('baseurl')));
//	$model->save();
//}
$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();
開發者ID:nicholasryan,項目名稱:CorePlus,代碼行數:31,代碼來源:next_page_updates.php


注:本文中的ContentModel::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。