描述
参数
获取子字段($选择器,[$format_value=true],[$escape_html=false]);
$选择器 (字符串) (必需) 子字段名称或字段键。 $格式_值 (布尔) (可选) 是否应用格式逻辑。 默认为true。 $escape_html (布尔) (可选) 自6.2.6起–返回字段值的转义HTML安全版本。 要求$format_value为true。 默认为false。
返回
示例
从Repeater字段中获取值。
if(have_rows('parent_field')): while(have_rows('parent_field')):the_row(); $sub_value=获取子字段('sub_field'); //做点什么。。。 endwhile; 其他: //找不到行 endif;
从“灵活内容”字段中获取值。
if(have_rows('parent_field')): while(have_rows('parent_field')):the_row(); //布局1。 如果(get_row_layout()==“布局1”): //布局1值。 $值=获取子字段('sub_field_1'); //布局2。 elseif(get_row_layout()==“布局_2”): //布局2值。 $值=获取子字段('sub_field_2'); endif; 结束时; endif;
嵌套循环连接
/** *字段结构: * *-parent_repeater(中继器) *-parent_title(文本) *-child_repeater(中继器) *-child_title(文本) */ if(have_rows(“父转发器”): while(have_rows('parent_reporter')):the_row(); //获取父值。 $parent_title=获取子字段(“父标题”); //在子转发器行上循环。 if(have_rows('child_reporter')): while(have_rows('child_reporter')):the_row(); //获取子值。 $child_title=获取子字段('child_ttitle'); endwhile; endif; 结束时; endif;