-
AuthorPosts
-
giuliano m Friend
giuliano m
- Join date:
- August 2008
- Posts:
- 117
- Downloads:
- 29
- Uploads:
- 33
- Thanks:
- 91
- Thanked:
- 14 times in 4 posts
March 6, 2013 at 6:43 pm #185579I updated the template to version 1.0.8 works, but I have this error only in certain categories of items.
Warning: Invalid argument supplied for foreach() in /home/mysite/templates/ja_wall/html/com_k2/ja_wall_blog/item.php on line 278
with firebug
<?php
//Check extrafield value as grid-double or grid-triple
if(count($this->item->extra_fields)):
foreach ($this->item->extra_fields as $key=>$extraField){
if ($extraField->value ==’grid-double’ || $extraField->value ==’grid-triple’) {
unset($this->item->extra_fields[$key]);
}
}endif;
?>but I do not understand what is the problem…
giuliano m Friendgiuliano m
- Join date:
- August 2008
- Posts:
- 117
- Downloads:
- 29
- Uploads:
- 33
- Thanks:
- 91
- Thanked:
- 14 times in 4 posts
March 6, 2013 at 8:34 pm #485641I solved, I think,:)
in the category of k2 options (Item view options) , the Extra Fields must be selected. (strange first it was not necessary)
-
3 users say Thank You to giuliano m for this useful post
jsventer Friendjsventer
- Join date:
- April 2010
- Posts:
- 19
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 7
- Thanked:
- 1 times in 1 posts
June 9, 2013 at 1:32 am #495223This can’t be the solution. What if we don’t want to show the extra-fields?
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
June 10, 2013 at 7:44 am #495276Hi,
We will fix this issue on next release of JA Wall.
For better, you can remove the block code above and add a simple line code as below in the next loop.
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value =='grid-double' || $extraField->value =='grid-triple') continue; ?>
<?php if($extraField->value != ''): ?>Hope it helps,
Regards
jsventer Friendjsventer
- Join date:
- April 2010
- Posts:
- 19
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 7
- Thanked:
- 1 times in 1 posts
June 15, 2013 at 10:14 am #495969Hi,
The problem is in the foreach statement, and it is probably related to the umpteenth deprecation from the glorious PHP developers.
I think the solution might be the one that stackOverflow suggest:if(is_array($this->item->extra_fields)):
foreach ($this->item->extra_fields as $key=>$extraField){
if ($extraField->value ==’grid-double’ || $extraField->value ==’grid-triple’) {
unset($this->item->extra_fields[$key]);
}
}endif;
Regards:
Javier
Wall Crasher DeveloperWall Crasher
- Join date:
- December 2011
- Posts:
- 1113
- Downloads:
- 0
- Uploads:
- 15
- Thanks:
- 66
- Thanked:
- 361 times in 300 posts
June 17, 2013 at 1:21 am #496001Hi jsventer,
Yes, the if condition will make the foreach safe. But we do not need to run the loop twice. That why I move to a single loop and it will gain a bit(very very small) performance.
Regards
AuthorPostsViewing 6 posts - 1 through 6 (of 6 total)This topic contains 6 replies, has 3 voices, and was last updated by Wall Crasher 11 years, 5 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum
items k2 Warning: Invalid argument supplied for foreach
Viewing 6 posts - 1 through 6 (of 6 total)