json ACF简单灵活内容页面生成器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json ACF简单灵活内容页面生成器相关的知识,希望对你有一定的参考价值。

<?php
/********************
* PAGE BUILDER
********************/
?>

<?php
if( have_rows('content') ):
  while ( have_rows('content') ) : the_row();

    // 1 COLUMN
    if( get_row_layout() == '1_column' ):

      echo '<section class="one-col cf">';

      // COLUMN CONTENT
      if( have_rows('column_content') ):

        echo '<div class="m-all t-all d-all builder-content cf">';

        while ( have_rows('column_content') ) : the_row();

          // WYSIWYG EDITOR
          the_sub_field('wysiwyg_editor');

        endwhile;

        echo '</div>';

      else :
      endif;

      echo '</section>';

    // 2 COLUMNS
    elseif( get_row_layout() == '2_columns' ):

      echo '<section class="two-col grid-skin cf">';

      // LEFT COLUMN CONTENT
      if( have_rows('left_column_content') ):

        echo '<div class="m-all mt-1of2 t-all d-1of2 with-padding builder-content cf">';

        while ( have_rows('left_column_content') ) : the_row();

          // WYSIWYG EDITOR
          the_sub_field('wysiwyg_editor');

        endwhile;

        echo '</div>';

      else :
      endif;

      // RIGHT COLUMN CONTENT
      if( have_rows('right_column_content') ):

        echo '<div class="m-all mt-1of2 t-all d-1of2 with-padding builder-content cf">';

        while ( have_rows('right_column_content') ) : the_row();

          // WYSIWYG EDITOR
          the_sub_field('wysiwyg_editor');

        endwhile;

        echo '</div>';

      else :
      endif;

      echo '</section>';

    // 2 COLUMNS
    elseif( get_row_layout() == '2_columns_1_third_2_thirds' ):

      echo '<section class="two-col grid-skin cf">';

      // LEFT COLUMN CONTENT
      if( have_rows('left_column_content') ):

        echo '<div class="m-all mt-all t-all d-1of3 with-padding builder-content cf">';

        while ( have_rows('left_column_content') ) : the_row();

          // WYSIWYG EDITOR
          the_sub_field('wysiwyg_editor');

        endwhile;

        echo '</div>';

      else :
      endif;

      // RIGHT COLUMN CONTENT
      if( have_rows('right_column_content') ):

        echo '<div class="m-all mt-all t-all d-2of3 with-padding builder-content cf">';

        while ( have_rows('right_column_content') ) : the_row();

          // WYSIWYG EDITOR
          the_sub_field('wysiwyg_editor');

        endwhile;

        echo '</div>';

      else :
      endif;

      echo '</section>';

    endif;


  endwhile;
else :
  // no layouts found
endif;
?>
[
    {
        "key": "group_57d2ab81d5362",
        "title": "Page Builder",
        "fields": [
            {
                "key": "field_57d2abe0157fc",
                "label": "Content",
                "name": "content",
                "type": "flexible_content",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "button_label": "Add Content",
                "min": "",
                "max": "",
                "layouts": [
                    {
                        "key": "57d2abefa7908",
                        "name": "1_column",
                        "label": "1 Column",
                        "display": "block",
                        "sub_fields": [
                            {
                                "key": "field_57d2ac0b157fd",
                                "label": "Column Content",
                                "name": "column_content",
                                "type": "repeater",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "collapsed": "",
                                "min": "",
                                "max": "",
                                "layout": "block",
                                "button_label": "Add Column Content",
                                "sub_fields": [
                                    {
                                        "key": "field_57d2acf6157fe",
                                        "label": "Wysiwyg Editor",
                                        "name": "wysiwyg_editor",
                                        "type": "wysiwyg",
                                        "instructions": "",
                                        "required": 0,
                                        "conditional_logic": 0,
                                        "wrapper": {
                                            "width": "",
                                            "class": "",
                                            "id": ""
                                        },
                                        "default_value": "",
                                        "tabs": "all",
                                        "toolbar": "full",
                                        "media_upload": 1
                                    }
                                ]
                            }
                        ],
                        "min": "",
                        "max": ""
                    },
                    {
                        "key": "57d2ad3d157ff",
                        "name": "2_columns",
                        "label": "2 Columns",
                        "display": "block",
                        "sub_fields": [
                            {
                                "key": "field_57d2ad4615800",
                                "label": "Left Column Content",
                                "name": "left_column_content",
                                "type": "repeater",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "collapsed": "",
                                "min": "",
                                "max": "",
                                "layout": "block",
                                "button_label": "Add Column Content",
                                "sub_fields": [
                                    {
                                        "key": "field_57d2ad5a15801",
                                        "label": "Wysiwyg Editor",
                                        "name": "wysiwyg_editor",
                                        "type": "wysiwyg",
                                        "instructions": "",
                                        "required": 0,
                                        "conditional_logic": 0,
                                        "wrapper": {
                                            "width": "",
                                            "class": "",
                                            "id": ""
                                        },
                                        "default_value": "",
                                        "tabs": "all",
                                        "toolbar": "full",
                                        "media_upload": 1
                                    }
                                ]
                            },
                            {
                                "key": "field_57d2ad9015802",
                                "label": "Right Column Content",
                                "name": "right_column_content",
                                "type": "repeater",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "collapsed": "",
                                "min": "",
                                "max": "",
                                "layout": "block",
                                "button_label": "Add Column Content",
                                "sub_fields": [
                                    {
                                        "key": "field_57d2ad9015803",
                                        "label": "Wysiwyg Editor",
                                        "name": "wysiwyg_editor",
                                        "type": "wysiwyg",
                                        "instructions": "",
                                        "required": 0,
                                        "conditional_logic": 0,
                                        "wrapper": {
                                            "width": "",
                                            "class": "",
                                            "id": ""
                                        },
                                        "default_value": "",
                                        "tabs": "all",
                                        "toolbar": "full",
                                        "media_upload": 1
                                    }
                                ]
                            }
                        ],
                        "min": "",
                        "max": ""
                    },
                    {
                        "key": "57e4f027f3764",
                        "name": "2_columns_1_third_2_thirds",
                        "label": "2 Columns (1\/3 and 2\/3)",
                        "display": "block",
                        "sub_fields": [
                            {
                                "key": "field_57e4f027f3765",
                                "label": "Left Column Content",
                                "name": "left_column_content",
                                "type": "repeater",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "collapsed": "",
                                "min": "",
                                "max": "",
                                "layout": "block",
                                "button_label": "Add Column Content",
                                "sub_fields": [
                                    {
                                        "key": "field_57e4f027f3766",
                                        "label": "Wysiwyg Editor",
                                        "name": "wysiwyg_editor",
                                        "type": "wysiwyg",
                                        "instructions": "",
                                        "required": 0,
                                        "conditional_logic": 0,
                                        "wrapper": {
                                            "width": "",
                                            "class": "",
                                            "id": ""
                                        },
                                        "default_value": "",
                                        "tabs": "all",
                                        "toolbar": "full",
                                        "media_upload": 1
                                    }
                                ]
                            },
                            {
                                "key": "field_57e4f027f3767",
                                "label": "Right Column Content",
                                "name": "right_column_content",
                                "type": "repeater",
                                "instructions": "",
                                "required": 0,
                                "conditional_logic": 0,
                                "wrapper": {
                                    "width": "",
                                    "class": "",
                                    "id": ""
                                },
                                "collapsed": "",
                                "min": "",
                                "max": "",
                                "layout": "block",
                                "button_label": "Add Column Content",
                                "sub_fields": [
                                    {
                                        "key": "field_57e4f027f3768",
                                        "label": "Wysiwyg Editor",
                                        "name": "wysiwyg_editor",
                                        "type": "wysiwyg",
                                        "instructions": "",
                                        "required": 0,
                                        "conditional_logic": 0,
                                        "wrapper": {
                                            "width": "",
                                            "class": "",
                                            "id": ""
                                        },
                                        "default_value": "",
                                        "tabs": "all",
                                        "toolbar": "full",
                                        "media_upload": 1
                                    }
                                ]
                            }
                        ],
                        "min": "",
                        "max": ""
                    }
                ]
            }
        ],
        "location": [
            [
                {
                    "param": "post_type",
                    "operator": "==",
                    "value": "page"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": 1,
        "description": ""
    }
]

以上是关于json ACF简单灵活内容页面生成器的主要内容,如果未能解决你的问题,请参考以下文章

php ACF灵活内容

php ACF灵活的内容

输出表中的 ACF 灵活内容字段(表头不通过循环重复)

php Acf Pro&Sage 9 - 灵活的内容块

如何隐藏 ACF 中灵活内容框中的复选框但不隐藏其他复选框

ACF 页面 while 循环在循环时中断页脚