Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • giuliano m Friend
    #185579

    I 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 Friend
    #485641

    I solved, I think,:)

    in the category of k2 options (Item view options) , the Extra Fields must be selected. (strange first it was not necessary)


    1. Screenshot_1
    jsventer Friend
    #495223

    This can’t be the solution. What if we don’t want to show the extra-fields?

    Wall Crasher Developer
    #495276

    Hi,

    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 Friend
    #495969

    Hi,

    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 Developer
    #496001

    Hi 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

Viewing 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