1

I have a News & Highlights section on a site homepage where I'm trying to pull in entries from either a News channel or the Calendar. For both it should pull in the latest 3 entries that are tagged with a category (Featured). I have it working for the most part, except that I am unable to show the date of the event from the Solspace calendar. I realize this is due to the fact that the date is not stored in the channel entries, but needs to be pulled in via calendar:events. However, when I do this, I am getting the same date for all events output.

           <h1 class="head"><a href="/News-and-Highlights">News and Highlights</a></h1>

{exp:channel:entries channel="news|calendar_events" category="17" limit="3"}
    <div class="span4">
    {if news_body != ""}<a href="{url_title_path="News-and-Highlights/Story/"}">
    {if:else}<a href="{url_title_path="Calendar/Event/"}">
    {/if}
    <span class="link-spanner">

          <div class="row-fluid news-header">
            {if news_picture==""}<a href="{url_title_path="News-and-Highlights/Story/"}" title="{title}"><img class="news-photo" src="/Default_Images/logoDefault.png" alt=""/></a>
            {if:else}<a href="{url_title_path="News-and-Highlights/Story/"}" title="{title}"><img class="news-photo" src="{news_picture}" alt=""/></a>
            {/if}
            <div class="news-inner">
              {if news_date != ""}<span class="date-meta"><a style="color:#989898;" href="{url_title_path="News-and-Highlights/Story/"}" title="{title}">{news_date format="%F %d, %Y"}</a></span>
              {if:elseif news_body != ""}<span class="date-meta"><a style="color:#989898;" href="{url_title_path="News-and-Highlights/Story/"}" title="{title}">Announcement</a></span>
              {if:else} <span class="date-meta"><a style="color:#989898;" href="{url_title_path="Calendar/Event/"}" title="{title}">{exp:calendar:events limit="1"}{event_start_date format="%F %d, %Y"}{/exp:calendar:events}</a></span>
              {/if}
              <h3><a style="color:#4463A0;" href="{url_title_path="News-and-Highlights/Story/"}" title="{title}">{title}</a></h3>
              <h3 class="italics">{if news_author != ''}{news_author}{/if}</h3>
            </div>

          </div>

          <p>
        {if news_body != ""}{exp:sk_excerpt chars='200'}{news_body}{/exp:sk_excerpt}
        {if:else}{exp:sk_excerpt chars='200'}{event_summary}{/exp:sk_excerpt}
        {/if}
          </p>
          <div class="triangle-bottom-right"></div>

          <a class="read-more" href="{url_title_path="News-and-Highlights/Story/"}" title="{title}">Read More <i class="icon-caret-right"></i></a>

        </div>
</span>        {/exp:channel:entries}
      </div>  <!-- end news -->
1

try adding this to your calendar:events tag

event_id="{entry_id}"

You may need to stick it into an embed if nesting a calendar tag inside a channel entries tag gives you trouble.


EDITED

I believe A better approach to accomplish what you're after would be to use a {exp:channel:entries} tag for your news and a {exp:calendar:cal} tag for your events.

If you need to limit the number of events returned by calendar tag see the event_limit parameter and this example. http://www.solspace.com/docs/calendar/calendar/#examples

Trying to get 3 entries from either channel would be tricky. A couple ideas are:

  1. You could build a stash list from the 2 tags and output only 3 items
  2. You could try to tweak the calendar_events entries entry_date (not calendar field date) and sort by it.

Without knowing a little more about what the news and events entries look like that's about all I can think of.

| improve this answer | |
  • Thanks! That did the trick. Now I just need to figure out if there's a way to use a conditional to just pull in future events from the calendar, but not the same for news. – susan Apr 2 '14 at 21:15
  • And the news channel entries would have entry dates in the past? – mjr Apr 2 '14 at 21:32
  • Well, not necessarily. The news entries that will stick around have their date field (expiration) set to the future. But I guess I'm not sure if it's possible to do what I want without creating an array of the events? It doesn't seem like the event_start_date is available to me outside exp:calendar:events. – susan Apr 2 '14 at 21:39
  • To get upcoming event data, use {exp:calendar:cal}, not {exp:calendar:events}. It's the only tag that will create a true chronological list of events based on the timeframe you set in the date_range_start="" and date_range_end="" parameters. I recommend this documentation page for more details: solspace.com/docs/calendar/getting_started – Solspace Apr 3 '14 at 2:58
  • I'm curious if there is a reason you need to use a single channel entries tag to get both news and events. If you could use {exp:channel:entries} to retrieve your news and {exp:calendar:cal} to retrieve your events that would accomplish what you are after. – mjr Apr 3 '14 at 13:17

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.