CMS操作

获取内容

MCms::getContent ( $id )
参数 类型 说明
$id integer 内容ID
返回
array
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 18:54:05",
  "updated_at": "2023-11-13 15:30:33",
  "catId": 10,
  "modelId": 4,
  "title": "标题",
  "summary": "摘要",
  "cover": "https://example.com/cover.jpg",
  "seoTitle": null,
  "seoDescription": null,
  "seoKeywords": null,
  "postTime": "2021-11-03 18:52:14",
  "wordCount": null,
  "viewCount": 388,
  "commentCount": null,
  "likeCount": null,
  "isRecommend": 1,
  "isTop": 1,
  "author": "作者",
  "source": "来源",
  "_url": "/news/2",
  "_tags": [
    "标签"
  ],
  "_tagList": [
    {
      "name": "标签",
      "url": "/tag/标签"
    }
  ],
  "_data": {
    "content": "富文本内容",
    "xxx": "自定义字段"
  }
}

获取内容副表字段

MCms::getContentData ( $record )
参数 类型 说明
$record array 主表记录
返回
array
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 18:54:05",
  "updated_at": "2021-11-03 19:12:59",
  "content": "内容",
  "xxx": "自定义字段"
}

获取内容副表单个字段

该方法会在内存中缓存副表数据以提高性能
MCms::getContentDataField ( $record, $fieldName, $default )
参数 类型 说明
$record array 主表记录
$fieldName string 字段名
$default mixed 默认值
返回
string|number

获取栏目

MCms::getCat ( $catId )
参数 类型 说明
$catId integer 栏目ID
返回
array
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 16:38:21",
  "updated_at": "2022-04-13 09:34:23",
  "title": "行业资讯",
  "subTitle": null,
  "bannerBg": null,
  "url": "news/kind1",
  "seoTitle": null,
  "seoDescription": null,
  "seoKeywords": null,
  "icon": null,
  "cover": "http://example.com/cover.jpg",
  "_url": "/news/kind1"
}

获取栏目(根据URL)

MCms::getCatByUrl ( $catUrl )
参数 类型 说明
$catUrl string 栏目URL
返回
array
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 16:38:21",
  "updated_at": "2022-04-13 09:34:23",
  "title": "行业资讯",
  "subTitle": null,
  "bannerBg": null,
  "url": "news/kind1",
  "seoTitle": null,
  "seoDescription": null,
  "seoKeywords": null,
  "icon": null,
  "cover": "http://example.com/cover.jpg",
  "_url": "/news/kind1"
}

获取子栏目

MCms::listCatChildren ( $catId )
参数 类型 说明
$catId integer 栏目ID
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 16:38:21",
    "updated_at": "2022-04-13 09:34:23",
    "title": "行业资讯",
    "subTitle": null,
    "bannerBg": null,
    "url": "news/kind1",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "icon": null,
    "cover": "http://example.com/cover.jpg",
    "_url": "/news/kind1"
  },
  ...
]

获取子栏目(根据URL)

MCms::listCatChildrenByUrl ( $catUrl )
参数 类型 说明
$catUrl string 栏目URL
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 16:38:21",
    "updated_at": "2022-04-13 09:34:23",
    "title": "行业资讯",
    "subTitle": null,
    "bannerBg": null,
    "url": "news/kind1",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "icon": null,
    "cover": "http://example.com/cover.jpg",
    "_url": "/news/kind1"
  },
  ...
]

获取栏目内容分页(含副表字段)

根据单个栏目ID获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentWithDataByCat ( $catId, $page, $pageSize, $option )
参数 类型 说明
$catId integer 栏目ID
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目内容分页(含副表字段)

根据多个栏目ID获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentWithDataByCats ( $catIds, $page, $pageSize, $option )
参数 类型 说明
$catIds int[] 栏目ID
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目内容分页(含副表字段)

根据单个栏目URL获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentWithDataByCatUrl ( $catUrl, $page, $pageSize, $option )
参数 类型 说明
$catUrl string 栏目URL
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目内容分页(含副表字段)

根据多个栏目URL获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentWithDataByCatsUrl ( $catUrls, $page, $pageSize, $option )
参数 类型 说明
$catUrls string[] 栏目URL
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目内容列表

根据栏目ID获取内容列表,不包含子栏目
MCms::listContentByCat ( $catId, $page, $pageSize, $option )
参数 类型 说明
$catId integer 栏目ID
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目内容列表(根据URL)

根据栏目URL获取内容列表,不包含子栏目
MCms::listContentByCatUrl ( $catUrl, $page, $pageSize, $option )
参数 类型 说明
$catUrl string 栏目URL
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目内容分页

根据单个栏目ID获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentByCat ( $catUrl, $page, $pageSize, $option )
参数 类型 说明
$catUrl string 栏目URL
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目内容分页(根据URL)

根据单个栏目URL获取内容分页,不包含子栏目,多个栏目必须为相同的模型
MCms::pageContentByCatUrl ( $catUrl, $page, $pageSize, $option )
参数 类型 说明
$catUrl string 栏目URL
$page integer 页码
$pageSize integer 分页大小
$option array 其他选项
// 简单条件(字段限定在主表记录)
$option = [ 'where'=>[ 'title'=>'新闻' ] ];
// 模糊搜索(字段限定在主表记录)
$option = [ 'whereOperate'=>[ 'title', 'like', '%关键词%' ] ];
// 副表关联搜索(关联副表 cms_m_xxx,同时搜索副表字段 title = 标题 的记录)
$option = [ 'fieldFilterTable'=>'cms_m_xxx', 'fieldFilter'=>[ [ 'condition'=>'is', 'field'=>'title', 'value'=>'标题' ] ] ];
返回
array
返回示例
{
  "total": 3,
  "records": [
    {
      "id": 2,
      "created_at": "2021-11-03 18:54:05",
      "updated_at": "2023-11-13 15:30:33",
      "catId": 10,
      "modelId": 4,
      "title": "标题",
      "summary": "摘要",
      "cover": "https://example.com/cover.jpg",
      "seoTitle": null,
      "seoDescription": null,
      "seoKeywords": null,
      "postTime": "2021-11-03 18:52:14",
      "wordCount": null,
      "viewCount": 388,
      "commentCount": null,
      "likeCount": null,
      "isRecommend": 1,
      "isTop": 1,
      "author": "作者",
      "source": "来源",
      "_url": "/news/2",
      "_tags": [
        "标签"
      ],
      "_tagList": [
        {
          "name": "标签",
          "url": "/tag/标签"
        }
      ],
      "_data": {
        "content": "富文本内容",
        "xxx": "自定义字段"
      }
    },
    ...
  ]
}

获取栏目最近内容列表

MCms::latestContentByCat ( $catId, $limit )
参数 类型 说明
$catId integer 栏目ID
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目最近内容列表(根据URL)

MCms::latestContentByCatUrl ( $cateUrl, $limit )
参数 类型 说明
$cateUrl string 栏目URL
$limit integer 数量
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目最近推荐内容列表

MCms::latestRecommendContentByCat ( $catId, $limit )
参数 类型 说明
$catId integer 栏目ID
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目最近推荐内容列表(根据URL)

MCms::latestRecommendContentByCatUrl ( $cateUrl, $limit )
参数 类型 说明
$cateUrl string 栏目URL
$limit integer 数量
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目随机内容列表

MCms::randomContentByCat ( $catId, $limit )
参数 类型 说明
$catId integer 栏目ID
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取模型内容推荐列表(使用的是推荐服务)

MCms::recommendContentByModel ( $modelId, $limit )
参数 类型 说明
$modelId integer 模型ID
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目置顶内容列表

MCms::latestTopContentByCat ( $catId, $limit )
参数 类型 说明
$catId integer 栏目ID
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取栏目置顶内容列表(根据URL)

MCms::latestTopContentByCatUrl ( $cateUrl, $limit )
参数 类型 说明
$cateUrl string 栏目URL
$limit integer 数量
返回
array
返回示例
[
  {
    "id": 2,
    "created_at": "2021-11-03 18:54:05",
    "updated_at": "2023-11-13 15:30:33",
    "catId": 10,
    "modelId": 4,
    "title": "标题",
    "summary": "摘要",
    "cover": "https://example.com/cover.jpg",
    "seoTitle": null,
    "seoDescription": null,
    "seoKeywords": null,
    "postTime": "2021-11-03 18:52:14",
    "wordCount": null,
    "viewCount": 388,
    "commentCount": null,
    "likeCount": null,
    "isRecommend": 1,
    "isTop": 1,
    "author": "作者",
    "source": "来源",
    "_url": "/news/2",
    "_tags": [
      "标签"
    ],
    "_tagList": [
      {
        "name": "标签",
        "url": "/tag/标签"
      }
    ],
    "_data": {
      "content": "富文本内容",
      "xxx": "自定义字段"
    }
  },
  ...
]

获取下一条内容

MCms::nextContent ( $catId, $recordId )
参数 类型 说明
$catId integer 栏目ID
$recordId integer 记录ID
返回
array|null
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 18:54:05",
  "updated_at": "2023-11-13 15:30:33",
  "catId": 10,
  "modelId": 4,
  "title": "标题",
  "summary": "摘要",
  "cover": "https://example.com/cover.jpg",
  "seoTitle": null,
  "seoDescription": null,
  "seoKeywords": null,
  "postTime": "2021-11-03 18:52:14",
  "wordCount": null,
  "viewCount": 388,
  "commentCount": null,
  "likeCount": null,
  "isRecommend": 1,
  "isTop": 1,
  "author": "作者",
  "source": "来源",
  "_url": "/news/2",
  "_tags": [
    "标签"
  ],
  "_tagList": [
    {
      "name": "标签",
      "url": "/tag/标签"
    }
  ],
  "_data": {
    "content": "富文本内容",
    "xxx": "自定义字段"
  }
}

获取上一条内容

MCms::prevContent ( $catId, $recordId )
参数 类型 说明
$catId integer 栏目ID
$recordId integer 记录ID
返回
array|null
返回示例
{
  "id": 2,
  "created_at": "2021-11-03 18:54:05",
  "updated_at": "2023-11-13 15:30:33",
  "catId": 10,
  "modelId": 4,
  "title": "标题",
  "summary": "摘要",
  "cover": "https://example.com/cover.jpg",
  "seoTitle": null,
  "seoDescription": null,
  "seoKeywords": null,
  "postTime": "2021-11-03 18:52:14",
  "wordCount": null,
  "viewCount": 388,
  "commentCount": null,
  "likeCount": null,
  "isRecommend": 1,
  "isTop": 1,
  "author": "作者",
  "source": "来源",
  "_url": "/news/2",
  "_tags": [
    "标签"
  ],
  "_tagList": [
    {
      "name": "标签",
      "url": "/tag/标签"
    }
  ],
  "_data": {
    "content": "富文本内容",
    "xxx": "自定义字段"
  }
}

判断当前用户是否可以访问该栏目

MCms::canVisitCat ( $cat )
参数 类型 说明
$cat array 栏目
返回
boolean

判断当前用户是否可以发布到该栏目

MCms::canPostCat ( $cat )
参数 类型 说明
$cat array
返回
boolean
QQ
微信
客服