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


PHP CMSCategory::add方法代码示例

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


在下文中一共展示了CMSCategory::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CMSCategory

<!--head-->
<script type="text/javascript" src="../js/tinymce/tinymce.min.js"></script>
<!--//head-->
<?php 
if (isset($_POST['sveCMSCategory']) && Tools::getRequest('sveCMSCategory') == 'add') {
    $cmscategory = new CMSCategory();
    $cmscategory->copyFromPost();
    $cmscategory->add();
    if (is_array($cmscategory->_errors) and count($cmscategory->_errors) > 0) {
        $errors = $cmscategory->_errors;
    } else {
        $_GET['id'] = $cmscategory->id;
        echo '<div class="conf">创建分类成功</div>';
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new CMSCategory($id);
}
if (isset($_POST['sveCMSCategory']) && Tools::getRequest('sveCMSCategory') == 'edit') {
    if (Tools::getRequest('id_parent') == $obj->id) {
        $obj->_errors[] = '父分类不能为当前分类!';
    } elseif (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        echo '<div class="conf">更新分类成功</div>';
    }
开发者ID:yiuked,项目名称:tmcart,代码行数:31,代码来源:cms_category_edit.php

示例2: create_category

 public static function create_category($parent, $name, $linkRewrite, $description = '', $meta_title = '', $meta_description = '', $meta_keywords = '')
 {
     $configuration = PS_CLI_CONFIGURE::getConfigurationInstance();
     $category = new CMSCategory();
     if (!Validate::isUnsignedId($parent)) {
         echo "Error, {$parent} is not a valid category ID\n";
         return false;
     }
     $parentCat = new CMSCategory($parent);
     if (!Validate::isloadedObject($parentCat)) {
         echo "Error: category {$parentCat} does not exists\n";
         return false;
     }
     $category->id_parent = $parent;
     if (!Validate::isName($name)) {
         echo "Error, {$name} is not a valid category name\n";
         return false;
     }
     $category->name = array($configuration->lang => $name);
     if (!Validate::isLinkRewrite($linkRewrite)) {
         echo "Error, {$linkRewrite} is not a valid link rewrite\n";
         return false;
     }
     $category->link_rewrite = array($configuration->lang => $linkRewrite);
     if (!Validate::isCleanHtml($description)) {
         echo "Warning, {$description} is not a valid category description\n";
         $description = '';
     }
     $category->description = array($configuration->lang => $description);
     if (!Validate::isGenericName($meta_title)) {
         echo "Warning, {$meta_title} is not a valid value for meta_title\n";
         $meta_title = '';
     }
     $category->meta_title = array($configuration->lang => $meta_title);
     if (!Validate::isGenericName($meta_description)) {
         echo "Warning, {$meta_description} is not a valid value for meta_description\n";
         $meta_description = '';
     }
     $category->meta_description = array($configuration->lang => $meta_description);
     if (!Validate::isGenericName($meta_keywords)) {
         echo "Warning, {$meta_keywords} is not a valid value for meta_keywords\n";
         $meta_keywords = '';
     }
     $category->meta_keywords = array($configuration->lang => $meta_keywords);
     if ($category->add()) {
         if ($configuration->porcelain) {
             echo $category->id_cms_category;
         } else {
             echo "Successfully created category {$category->id_cms_category}\n";
         }
         return true;
     } else {
         echo "Error, could not create category {$name}\n";
         return false;
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:56,代码来源:cms.php

示例3: importCMSCategories

 protected function importCMSCategories()
 {
     $this->truncateTables(array('cms_category', 'cms_category_lang', 'cms_category_shop'));
     $handle = $this->openCsvFile('cms_categories.csv');
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $fields = $this->filterFields('CMSCategory', $this->cms_category_fields, $line);
         if (!isset($fields['id'])) {
             $cms_cat = new CMSCategory((int) $line[0]);
             $cms_cat->id = $line[0];
         } else {
             $cms_cat = new CMSCategory((int) $fields['id']);
         }
         foreach ($fields as $key => $field) {
             if ($key == 'name' || $key == 'description' || $key == 'meta_keywords' || $key == 'meta_description' || $key == 'link_rewrite') {
                 $cms_cat->{$key} = $this->multilFild($field);
             } else {
                 $cms_cat->{$key} = $field;
             }
         }
         $cms_cat->force_id = 1;
         if (!$res) {
             $cms_cat->add();
         }
     }
     $this->closeCsvFile($handle);
     return true;
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:28,代码来源:AdminSampleDataInstallImport.php


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