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.

Variables in loops

February 01, 2012 2:12pm

Subscribe [3]
  • #1 / Feb 01, 2012 2:12pm

    burnsDK

    2 posts

    Hi

    Is it possible to create dynamic variables in a channel entries tag. What I need is something like the following:

    {dynamic_var="36000"}

    {timeslots orderby="start_time"}

    {if {start_time} > {dynamic_var}}
    {dynamic_var="43200"}
    <h1>10-12</h1>
    {/if} 

    <tr class=”{switch="even|odd"}”>
    <td class=“col1”>{start_time format="%H:%i"}</td>
    <td class=“col2”>-</td>
    <td class=“col3”>{end_time format="%H:%i"}</td>
    <td class=“col4”>{title_{language_code}}</td>
    </tr>
    {/timeslots}


    or maybe even increment it like {dynamic_var="+7200"}

    The functionality I’am looking for is to write a header for every two hour timeslots.

  • #2 / Feb 01, 2012 2:33pm

    mark186282

    290 posts

    super easy to do in PHP, which you can employ directly in the template…

    I don’t know of a way specifically to do this in native EE code.

    If you’re interested in the PHP implemention, I can give an example to get you rolling

  • #3 / Feb 02, 2012 2:26am

    burnsDK

    2 posts

    Thanks a lot, it would be great to see a php example 😊

  • #4 / Feb 02, 2012 3:34am

    mark186282

    290 posts

    what’s the “timeslots” tag doing for ya?

    I assume it’s a list of available times for whatever you’re doing.  Is this dynamic? an array of data? result from the DB?

  • #5 / Feb 02, 2012 6:53pm

    Sean C. Smith

    3818 posts

    Hi burnsDK,

    As mark suggested the best way to do this would be to use php in your templates. It looks like Mark is getting ready to give you some help with that code as well, which is awesome. If you like I could move this thread over to community support.

    Sean

  • #6 / Feb 03, 2012 4:23am

    burnsDK

    2 posts

    Hi Mark

    Sorry for the late reply - I had a teaching job yesterday.

    The timeslots is a P&T Matrix tag - sorry I should have written this in the first place.

    Sean, fell free to move 😊

  • #7 / Feb 06, 2012 4:29pm

    Shane Eckert

    7174 posts

    Hello Mark and burnsDK,

    I will move this post over to Community for you.

    If there is anything else we can do for you, please let us know.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases