Inheritance: extends field
Esempio n. 1
0
 /**
  * @return string
  */
 protected function get_brick_html()
 {
     $html = '';
     while ($this->have_rows('modules')) {
         $this->the_row();
         $html .= acf_fields\flexible_content::get_sub_field_brick_instance()->get_html();
     }
     return $html;
 }
Esempio n. 2
0
 /**
  * @return string
  */
 protected function get_brick_html()
 {
     $html = '';
     while ($this->have_rows('modules')) {
         $this->the_row();
         /** @noinspection PhpUndefinedMethodInspection */
         $html .= acf_fields\flexible_content::get_sub_field_brick_instance()->get_html();
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * @param \fewbricks\acf\fields\repeater|\fewbricks\acf\fields\flexible_content|\fewbricks\bricks\brick $object_to_prepare_for
  * @param $setting
  */
 private function prepare_label_addition($object_to_prepare_for, $setting)
 {
     if ('' !== ($field_label_extra = $object_to_prepare_for->get_setting('field_label_' . $setting, ''))) {
         // If the break we are dealing with has a prefix, we need to respect that.
         if ('' !== ($my_field_label_extra = $this->get_setting('field_label_' . $setting, ''))) {
             $field_label_extra .= ' - ' . $my_field_label_extra;
         }
         $this->set_setting('field_label_' . $setting, $field_label_extra);
     }
 }
$fewbricks_fg = new fewacf\field_group('Fewbricks Demo - 3 Columns', '1509141034o', $fewbricks_fg_location, 20);
$fewbricks_fg->add_brick((new bricks\demo_flexible_columns('fcol1', '1509141034p'))->set_arg('nr_of_columns', 3));
$fewbricks_fg->register();
/**
 * 2 Columns.
 * Note that we are using the same brick as for the three columns above but passing 2 instead of 3 as nr of columns.
 */
$fewbricks_fg = new fewacf\field_group('Fewbricks Demo - 2 Columns', '1603242355a', $fewbricks_fg_location, 30);
$fewbricks_fg->add_brick((new bricks\demo_flexible_columns('fcol2', '1603242355b'))->set_arg('nr_of_columns', 2));
$fewbricks_fg->register();
/**
 * Flexible content on the fly.
 * Showing how it is possible to build complex flexible contents on the fly
 */
$fewbricks_fg = new fewacf\field_group('Fewbricks Demo - Flexible content on the fly', '1509111453p', $fewbricks_fg_location, 35);
$fewbricks_fc = new acf_fields\flexible_content('Flexible content 1', 'fc1', '150901113c');
// Leave name empty of you want it o be set to the same as that of the brick that you add
$fewbricks_l = new fewacf\layout('', 'layout_1', '1509042218o');
$fewbricks_l->add_brick((new bricks\demo_video('video', '1509042222u'))->set_arg('no_bg_color', true));
$fewbricks_fc->add_layout($fewbricks_l);
$fewbricks_l = new fewacf\layout('', 'layout_2', '1509060002y');
$fewbricks_l->add_brick(new bricks\demo_buttons_list('blist2', '1509060001t'));
$fewbricks_fc->add_layout($fewbricks_l);
$fewbricks_fg->add_flexible_content($fewbricks_fc);
$fewbricks_fg->register();
/**
 * Buttons list
 * Check demo_buttons_list to see how to set up repeaters.
 */
$fewbricks_fg = new fewacf\field_group('Fewbricks Demo - Buttons list', '1509111339o', $fewbricks_fg_location, 40);
$fewbricks_fg->add_brick((new bricks\demo_buttons_list('buttons_list', '1509052316o'))->set_field_label_prefix('Button list'));
?>

      <hr>

      <?php 
echo (new \fewbricks\bricks\demo_flexible_columns('fcol2'))->get_html();
?>

      <hr>

      <?php 
// loop through the rows of data
while (have_rows('fc1')) {
    the_row();
    /** @noinspection PhpUndefinedMethodInspection */
    echo \fewbricks\acf\fields\flexible_content::get_sub_field_brick_instance()->get_html(false, 'demo-layout-2');
}
?>

      <hr>

      <?php 
echo (new \fewbricks\bricks\demo_buttons_list('buttons_list'))->get_html(false, ['demo-layout-1']);
?>

      <hr>

      <?php 
echo (new \fewbricks\bricks\demo_standard_list('a_list'))->get_html(false, ['demo-layout-2']);
?>
<code>
    <?php 
echo highlight_string($snippet, true);
?>
</code>

<p><b>..outputs all of the below between the red lines</b></p>

<div class="demo-output-wrapper">

    <?php 
// loop through the rows of data
while (have_rows('fc1')) {
    the_row();
    echo \fewbricks\acf\fields\flexible_content::get_sub_field_brick_instance()->get_html();
}
?>

</div>






<h2 class="demo-h2">Field Group "Main content 4"</h2>

<p><b>This code:</b></p>

<?php 
Esempio n. 7
0
$fg = new fewacf\field_group('Main content 1', '150901113b', $location, 1);
// Add some fields
$fg->add_field(new acf_fields\text('Some texts', 'some_text', '1509011120p'));
$fg->add_field(new acf_fields\text('Some more text', 'some_more_text', '1509011120x'));
// Add a brick
$fg->add_brick((new bricks\demo_video('video_1', '1509011120x'))->set_field_label_prefix('A great video'));
// Register the field group
$fg->register();
// --- FIELD GROUP 2 ---
$fg = new fewacf\field_group('Main content 2', '1509111339o', $location, 2);
$fg->add_brick((new bricks\demo_buttons_list('button_list', '1509052316o'))->set_field_label_prefix('Button list'));
$fg->add_brick((new bricks\demo_standard_list('a_list', '1509042107u'))->set_field_label_prefix('A list'));
$fg->register();
// --- FIELD GROUP 3 ---
$fg = new fewacf\field_group('Main content 3', '1509111453p', $location, 3);
$fc = new acf_fields\flexible_content('Flexible content 1', 'fc1', '150901113c');
// Leave name empty of you want it o be set to the same as that of the brick that you add
$l = new fewacf\layout('', 'layout_1', '1509042218o');
$l->add_brick((new bricks\demo_video('video', '1509042222u'))->set_arg('no_bg_color', true));
$fc->add_layout($l);
$l = new fewacf\layout('', 'layout_2', '1509060002y');
$l->add_brick(new bricks\demo_buttons_list('blist2', '1509060001t'));
$fc->add_layout($l);
$fg->add_flexible_content($fc);
$fg->register();
// --- FIELD GROUP 4 ---
$fg = new fewacf\field_group('Main content 4', '1509111553y', $location, 4);
$fg->add_brick(new bricks\demo_flexible_brick('fb1', '1509111553r'));
$fg->register();
// --- FIELD GROUP 5 ---
$fg = new fewacf\field_group('Main content 5', '1509141034o', $location, 5);
Esempio n. 8
0
 /**
  * @param \fewbricks\acf\fields\flexible_content $flexible_content
  * @return fields\flexible_content
  */
 public function add_flexible_content($flexible_content)
 {
     $this->settings['fields'][] = $flexible_content->get_settings($this);
     return $flexible_content;
 }