• Hello!

    Code in a template runs in the global context. Code in the widget will run in a function context. Make sure that you declare any global variables as global before attempting to use them”

    What does that mean?
    How do i configure the code below to work in my widget that can handle php?

    <?php $lunch = get_group('lunch');  foreach($lunch as $lunch){
    echo '<span class="lunch-dag">' . $lunch['lunch_dag'][1]. '</span><br />';
    echo '<span class="lunch-matratt">' . $lunch['lunch_matratt'][1]."<br />";
    echo $lunch['lunch_matratt'][2]."<br />";
    echo $lunch['lunch_matratt'][3]."<br />";
    echo $lunch['lunch_matratt'][4]. '</span><br /><br />';}?>

    The code works perfect in a template!

    Best regards
    Andy

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter AndySwede

    (@andyswede)

    That´s the widget i use but my code doesn´t work in it!
    My code works when i use it in a template but not in this widget.

    This is what the creator of the widget says…

    “Code in a template runs in the global context. Code in the widget will run in a function context. Make sure that you declare any global variables as global before attempting to use them”

    …but i dont know how to achieve this change in my code!

    Best regards
    Andy

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Php in widget issue!’ is closed to new replies.