• Resolved TootsieRoll

    (@tootsieroll)


    I’m trying to use duplicate a Magic Fields group and I just can’t get it to work.
    Here’ s the code that I am using in my template:

    <?php
    	$column_2 = getGroupOrder('column_2');
    	foreach($column_2 as $column_two){
    		echo get('column_2_news_headline', $column_two)."<br />";
    		echo get('column_2_news_paragraph', $column_two)."<br /><br />";
    	}
    ?>

    And it’s outputting this pretty error:
    Warning: Invalid argument supplied for foreach()

    I read that I could get rid of the error but throwing an in statement in there like this:

    <?php
    	$column_2 = getGroupOrder('column_2');
    	if($column_2) {
    	foreach($column_2 as $column_two){
    		echo get('column_2_news_headline', $column_two)."<br />";
    		echo get('column_2_news_paragraph', $column_two)."<br /><br />";
    	}}
    	?>

    The error isn’t there anymore, but it’s not out putting my content either…
    I’m not super knowledgable in php yet, but I’d like to get better at it, can anyone help me?

Viewing 1 replies (of 1 total)
  • Thread Starter TootsieRoll

    (@tootsieroll)

    I’ve sorted it out:

    <?php
    	$column_2 = get_group('Column 2');
    	if($column_2) {
    	foreach($column_2 as $column_two){
    		echo $column_two['column_2_headline'][1]."<br />";
    		echo $column_two['column_2_text'][1]."<br />";
    	}}
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Magic Fields duplicates php error’ is closed to new replies.