ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

PHP gets broken when making an array

January 27, 2011 8:10am

Subscribe [4]
  • #1 / Jan 27, 2011 8:10am

    This question may be related to a resolved thread.

    If this works

    <?php $counter = {count};  if ($counter % 3 == 0){echo "</li><li>";}; ?>

    why does this not work?

    <?php $test = array({exp:weblog:entries weblog="default" 
    orderby="random" sort="desc" limit="3" }{if count!=1},{/if}{entry_id}
    {/exp:weblog:entries});echo $test[0];?>

    normal behaviour would be that it writes an array and then write the first entry to the screen.

    Any ideas?

  • #2 / Jan 27, 2011 5:45pm

    Ingmar

    29245 posts

    This looks horribly convoluted. What exaclty are you trying to achieve? It can be a bit tricky at times to get the parse order right between EE and PHP.

  • #3 / Jan 28, 2011 5:07am

    What i want to achieve is to grab 3 random items and display them on different positions in the page so i have

    this layout:
    3 items channel x
    1 random channel Y
    3 items channel x
    1 random channel Y ( but not previous random item)
    3 items channel x
    1 random channel Y ( the remaining random item)

    Any suggestion?

  • #4 / Jan 28, 2011 3:24pm

    Sue Crocker

    26054 posts

    Are you trying PHP in input or output row? Also wanted to warn you, this may end up going to the CodeShare Corner.

  • #5 / Jan 31, 2011 5:02am

    the PHP is on output. the desired effect is for the code area but the PHP problem is a wierd thing that bugs at the moment

  • #6 / Feb 01, 2011 2:28am

    John Henry Donovan

    12339 posts

    This thread is more appropriate for the CodeShare Corner so moving it there.
    You will hopefully get some of the community to brainstorm this with you

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases