Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am using contemplate on my site.
On some pages, this error message might appear:
warning: Invalid argument supplied for foreach() in /home/activ41/public_html/site/sites/all/modules/contemplate/contemplate.module(765) : eval()'d code on line 66.
In my contemplate, I am using the following foreach command:
<div class="course_page_block">
<h2 class="lc"> Syllabus Materials</h2>
<ul class="rc">
<?php
<?php foreach($node->field_link_to_support as $delta => $field) : ?>
<?php if ($node->field_link_to_support as $delta => $field): ?>
<h2><?php print '<li> Link: '.$node->field_link_to_support[$delta]['view'].'</li>';?></ul>
<?php endif; ?>
</div>
I can't see anything wrong with the code that should cause the error message to appear.
I know that Contemplate 5x is no longer supported, but I was wondering if someone could give me some pointers.
Comments
Comment #1
jrglasgow CreditAttribution: jrglasgow commentedyou get the "Invalid argument supplied for foreach()" error when the variable
$node->field_link_to_support
is not of a type that can be used (object or array) or the variable$node->field_link_to_support
is emptyI would try
Comment #2
littly_kitty CreditAttribution: littly_kitty commentedThanks for your help!
When I try that code I get an unexpected T_AS error.
I have had a careful look at the code, but I can't see anything wrong. (Other than the stray
<H2>
tag, 5 lines up from the bottom)I'm really not sure what I am doing wrong, so any help would be appreciated.