Home Forums Add-ons Repeater Field True false in repeater


True false in repeater

  • I Try to manage something like this, but the sub_field “zusatzbutton” doesn’t work.
    Any thought?

    		$seite = get_field('seite');
    		$zusatzbutton = get_sub_field('zusatzbutton-check');
    		if($seite) {
    		  echo '<div class="seiten grid-3 wrapper">';
    		     foreach($seite as $s) {
    		         echo '
    		         <div class="seite column">
    	              <div class="seite-bild"><a href="'.$s['button-link'].'"><img src="'.$s['seite-bild'].'"></a></div>
    	              <a class="weiterlesen" href="'.$s['button-link'].'">'.$s['button-text'].'</a>';
                   		if($zusatzbutton == 'yes') {
                   			echo '<a class="weiterlesen" href="'.$s['zusatzbutton-link'].'">'.$s['zusatzbutton-text'].'</a>';
    		         echo '</div>';
    		  echo '</div>';
  • You can’t use get_sub_field() unless you are in a have_rows() loop.

    This will return an array of rows

    $seite = get_field('seite');

    where each element of the array is a row with nested elements for each field
    example representation of this value:

    $seite = array(
        // row 1
        'zusatzbutton-check' => 1, / some value for this sub field
        'second-sub-field' => 'value of this field',
        // etc... 
        // row 2
        // etc...

    Have rows loop

    if (have_rows('seite')) {
      while (have_rows('seite')) {
        if (get_sub_field('zusatzbutton-check')) {
          // show information about this row
          // for more information see the link provided for have_rows()
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘True false in repeater’ is closed to new replies.