1

How to get and output entries like this ( example event Agenda )

  • day01
  • —session time-span ( loops session timespan entries )
  • ——session span entrie(s) ( one or multiple )
  • ——session span entries ( one or multiple )
  • ——session span entries ( one or multiple )
  • —/session time-span
  • —session time-span
  • ——session span entries ( one or multiple )
  • —/session time-span
  • /day01

-day02 ........

If anyone has input on how to do something like this ( still having the template readable :) )

I would be very thankful.

edit : my template ended up looking like this .. added storing a lastday variable to get days in the loop .. ( perhaps it can be done even better - but it works like a charm thanks for the input guys )

Blockquote {!--keep track of previous day in order to check if we have a new day--} {exp:string:set name="lastDay"}just starting{/exp:string:set}

**strong text**
    {exp:channel:entries channel="session_timeblocks" show_expired="yes" show_future_entries="yes" dynamic="no" limit="999" orderby="date" sort="asc"}

    {!-- store start day and time of current entry for check later on --}
    {exp:string:set name="currentDay"}{entry_date format="%d"}{/exp:string:set}

    {exp:string:output random}
    {if currentDay != lastDay}
        {if lastDay != "just starting"}
            -2-</div> {!-- close open session and day --}
        {/if}
    <div class="prog_day grid item{currentDay}" >-1-
        <div class="prog_day_title" >{entry_date format="%D %j/%n"}</div>
    {/if} 
    {/exp:string:output}


    <div class="prog_time grid">
        <div class="col-1-6">
            <div class="module">
                {entry_date format="%H:%i"} - {expiration_date format="%H:%i"}
            </div>
        </div>
        <div class="prog_session col-5-6" >
            <div class="module">
                {exp:playa:children field="{cf_session_timeblock}"}

                <h5>{title}</h5>
                <ul class='foldable'>
                    <li>
                        {if cf_session_summary}
                        <div>
                            <h3>Summary</h3>
                            <p>{cf_session_summary}</p>
                        </div>
                        {/if}
                    </li>
                </ul>
                {/exp:playa:children}
            </div>
        </div>
    </div>

    {!--store current entries start day and time--}
    {exp:string:set name="lastDay" random}{entry_date format="%d"}{/exp:string:set}
    {if count == total_results}2</div>{/if}

    {/exp:channel:entries}

Blockquote

3
  • How is the data stored in your system, or would that be part of the solution you are looking for? – nonprofit_tech Jan 23 '13 at 13:09
  • I got a 1)start and 2)stop date a 3)title and a 3)description (more fields related to description put those are easy to layout i ul or div tags, if the other loop(s) works). If you have and idea on how to store the Data - Sure I'll take that input too. Haven't been working with EE long ... so having alot of these nice 'aha' experiences:) – bomanden Jan 23 '13 at 13:17
  • are the day session parts (registration, lunch, workshop, etc.) separate entries? Then you can work with date_heading. Or, do you put them in a matrix and order them manually (much more easy, time - title - link) – GDmac Jan 23 '13 at 13:49
3

Based on your example, it seems very similar to something I have done before. There's actually several ways to do it depending on how comfortable you are with queries. To do it natively would be a bit more complex. One way I can envision you doing it is to have en "events" channel, wherein you create the profile of each event. And then you would have a second channel of time blocks. In the time blocks channel, you would create an entry for each block of time with a label, using the entry date fields as the start date/time and the expiry date as the end date/time. The reason I recommend that is that it allows you to retain the date headings tag pair functionality, which unfortunately natively only works with the built-in date fields. The result would be a channel entries loop of date blocks for which you can use the date headings to pump out a date heading for each day of your event, for example, with each block within each date then displaying the start time and end time and label for the block. Within each block, you would then need to display the list of events from your events channel that are assigned to that date block. For this, you could use either a relationship field OR even better, Pixel & Tonic's Playa add-on. Playa would allow you to have a single session description appear in more than one session block (so if the same event - like a presentation - actually gets presented more than once over the course of the event, one entry is used for each instance).

So your date blocks loop would look like this, roughly:

{exp:channel:entries channel="time_blocks" show_expired="yes" show_future_entries="yes" dynamic="no" limit="50" orderby="date" sort="asc"}

{date_heading display="daily"}  <h1>{entry_date format="%Y %m %d"}</h1>  {/date_heading}

{entry_date format="%H:%i} - {expiration_date format="%H:%i"}
{title}

{exp:playa:children field="block_events"}
{title}
{/exp:playa:children}

{/exp:channel:entries}

This assumes that you set up a Playa field in your blocks channel called "block_events" in which you select all the sessions occuring at that time. It might actually be better to do the reverse in the strictest sense, allowing you to add sessions and assign them in the event channel to their parent time block(s) but when you are displaying the list of time blocks as the parent list with the need to break that list up by date heading, this way may be just a bit friendlier to that.

Hope this helps.

8
  • Thanks for the quick input Jean. Will it out - got a license of the playa for the site allready to apply speakers to each session/events .. Will it be possible to add different timeblocks per day .. Just gotta read your input through a few times - and try it out :) it makes sence. thanks!. – bomanden Jan 23 '13 at 13:44
  • but your right a native loop - quickly gets messy :) – bomanden Jan 23 '13 at 13:45
  • Yes, each time block would be a distinct entry with a "parent" relationship to the sessions you pick to be assigned to it. The main thing you'll have to contend with is labeling via the title. When you see the edit list in your channel, you may have more than one of them called "registration" for example. So you may want to add a separate custom field for the "visible" title used in the front end so you can use the "real" title as an internal-only thing and name them more distinctly to make it easier to filter/manage. – Jean St-Amand Jan 23 '13 at 15:13
  • Incidentally, I like @nonprofit_tech's suggestion of Matrix, which would then contain all of your events within your time block entry distinctly, but if you have a lot of information about each event within a time block to convey, you may wind up needing a lot of columns in your matrix field to make it all work. And if the same session is help more than once in your schedule, but simply at a different time, this approach means repeating the session profile (unless you use Playa as a matrix field, but I digress...). – Jean St-Amand Jan 23 '13 at 15:17
  • Having date blocks and sessions as separate entries also gives you the ability to add a third dimension to it - speakers as entries- another thing I have done before in the same kind of setup. – Jean St-Amand Jan 23 '13 at 15:18
3

There are a number of options available. You could use Matrix to store sessions related to a time block, like Day 1 or 10am-12pm. You could use categories for your main and sub-groups: Day 1 as parent, Time blocks (10am-12pm) as sub-categories. Or you could use an add-on like Playa to create relationships.

Here are some examples.

Matrix Option

With Matrix, you'd probably want to enter each 'session' under time blocks. There's other ways to do it, but let's assume you have a record 'Day One' in ExpressionEngine. Then that record could contain a Matrix field called sessions. Each line in Matrix could contain date, start_time, end_time, title, and description. This works fine if you have a small number of sessions, and have to create new agendas all year long, say for Board Meetings. I wouldn't really use it for say a conference with hundreds of sessions.

Code Sample: Matrix This code is untested, but should provide a general idea.

{exp:channel:entries site="meetings" channel="agendas" limit="3" url_title="{segment_3}" orderby="title" sort="asc"}

<h2>{title}</h2>
<p>{day_description}</p>

    <h3>Agenda</h3>
    <!-- Matrix: Uses Its Own Tagged Pairs, based on field_name -->
    <ol>{agenda}

      <li>{start_time}-{end_time}: <strong><a href="#">{title}</a><span class="hide"><br />{description}</span></li>

    {/agenda}</ol>

{/exp:channel:entries}

Playa Option

Playa probably offers the most flexibility of the options. What you would do, is set-up the fields as you described in your comment above. Storing each session as individual entries. Create a new channel in EE, and use that to assign sessions to a master grouping. That grouping could be the day or the time block, which ever is most important to you.

So for example, you could have a record in 'events' your master block, that relates all session to that record. While 'sessions' would be the current channel storing entries. The names could be however you like.

Code Sample: Playa This code is untested, but should provide a general idea.

{exp:channel:entries channel="event" orderby="date" sort="desc" limit="1" track_views="one"}

{date_heading}
<h3 class="date">{entry_date format=' %l, %F %d, %Y '}</h3>
{/date_heading}

<h2>{title}</h2>
<div style="margin-top: 0; margin-bottom: 20px;">
    <p class="summary">{event_summary}</p>
</div>

<h3>Agenda</h3>
<ol class="reverse">{exp:playa:children}

    <li><p>{start_time}-{end_time}: <a href="{comment_url_title_auto_path}" title="{title}"><strong>{title} &raquo;</strong></a></p><p class="hide">{description}</p></li>

{/exp:playa:children}</ol>
{/exp:channel:entries}

Playa can handle nested relations, which provides increased flexibility. But if you have pre-defined time slots, you can also create a 'Playa' field for each time period, and do very direct relations. Like these five sessions happen at 10am, these five at 12:30pm, etc.

No example for the category option. But categories are a nice quick way to group items, without dropping down into PHP. I've also used Low ReOrder to create groupings of items. It's nice, because you can technically reorder the items however you like.

If you want or need, very simple, you can do something like this example, with just basic EE code, no add-ons.

Example Code: No Add-Ons

The no add-on option, just uses EE's date functions group based on day and time. This is an annual event, so we also limit by year, so people can go back and view previous years schedules. We went for a pretty simple list design, but you can show hide items how ever you like.

{exp:channel:entries channel="schedule" year="2011" orderby="date" sort="asc" limit="50" dynamic="off" show_future_entries="yes"}

   {date_heading display="daily"}<h1 class="schedule-day" align="center">{entry_date format="%D, %F %d, %Y""}</h2>{/date_heading}

   {date_heading display="hourly"}
    <h2 class="schedule-time" align="center">{entry_date format="%g:%i %A"}</h2>
   {/date_heading}

   <div class="schedule">

       <h3><a href="{domain}/schedule/article/{url_title}" title="{title}">{title} &raquo;</a></h3>
       {if event_tagline !=""}<p><b>{event_tagline}</b>{/if}
       {if event_tagline ==""}<p>{if:else}<br />{/if}{entry_date format="%h:%i %A"} at <u>{event_location}</u> (Length: {event_length})
       <br /><br />{exp:word_limit total="60"}{exp:tagstripper:tagsToStrip keep="b,i,u"}{event_description}{/exp:tagstripper:tagsToStrip}{/exp:word_limit}</p>

  </div>

{/exp:channel:entries}
4
  • I went Jean's option ( didn't see your answers before doing it the 'playa way' ) and it works like a charm ! ( why cant I give two correct answers ? you really deserve it ). Thanks for the great input - really opened up my eyes on how both playa and matrix can be used to avoid these messy loops with the native way of doing stuff ... REALLY appreciate it what a eye opener ! . THANKS ALOT. – bomanden Jan 23 '13 at 17:09
  • No problem. EE is really flexible. Some times there are just a lot of ways to do something, and Playa is a great add-on. I saw Jean's answer post as I was typing. I decided to not look at it, because this site, ExpressionEngine® Answers is low on multiple answers. And I know once I read a good response, I'm more inclined to be 'yeah, what he said' than to write something different. – nonprofit_tech Jan 23 '13 at 17:36
  • I'm having one issue with the playa once your in the playa loop - how do you output a custom field from the parent. in the playa loop it checks if there is more than one children . if there is I would like to output a custom field from the timeblock entry that holds the playa field – bomanden Jan 25 '13 at 10:06
  • Can you write this up as a new question and put your example code in it? You can reference this question, or just give a brief background. I need to see some code. – nonprofit_tech Jan 25 '13 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.