wmd/section-and-product-type

如果你正在构建一些页面内容构建器,这个字段类型非常有用

2.0.8 2024-03-26 16:46 UTC

This package is auto-updated.

Last update: 2024-09-26 17:48:51 UTC


README

要求

此插件需要 Craft CMS 3.0.0-beta.23 或更高版本。

安装

要安装此插件,请按照以下说明操作。

  1. 打开你的终端并转到你的 Craft 项目目录

     cd /path/to/project
    
  2. 然后告诉 Composer 加载插件

     composer require wmd/section-and-product-type
    
  3. 在控制面板中,转到设置 → 插件,点击“安装”按钮以安装“Section And Product Type”。

Section And Product Type 概览

此插件是一个用于选择章节和商业产品类型的字段。

配置 Section And Product Type

当你使用这些类型之一创建字段时,你可以选择哪些章节或产品类型可用于选择。可以启用多选,这使得可以同时选择多个元素。

使用 Section And Product Type

步骤

  1. 安装插件;
  2. 创建和配置字段;
  3. 将字段添加到章节类型;

在模板中使用

{# section field #} 

{% set sectionsIds = enty.mySectionField %}
{% set sections = craft.entries.sectionId(sections).all() %}

{% for section in sections %}
   {# code for output #}
{% endfor %}   

{# product type field #} 

{% set productTypeIds = enty.myProductTypeField %}
{% set products = craft.products().typeId(productTypeIds).all() %}

{% for product in products %}
       {# code for output #}
{% endfor %}

此插件基于插件 https://github.com/charliedevelopment/craft3-section-field 的逻辑,感谢作者。

WMD Hosting 提供