Jump to content

Featured Events feedblock


BN_IT_Support

Recommended Posts

Posted

Does anyone know if there is a way to create a feed block to pull just the featured events from a calendar and sort then by start date please.  Even a way to filter and sort in the actual content template would be helpful.

Thanks

  • 1 month later...
  • 2 months later...
Posted

Do some prep......in Pages, create a new plugin Block based on the "Calendar->Upcoming Events". Populate the details in there (up to you) but on the Content tab, change the 'use this template as-is' field to 'Use as a base for a custome template'

Save it.

I'll be back in a little while with the code to put in, once I've ironed out a couple of things.

Posted

This will get you started - put this in as the content code. Following caveat applies: if there are no featured events then it will still display if there are any upcoming events (as it is based on that block, and $events is a list of all upcoming events, including featured ones) so the 'Automatically hide...' option on the block won't work as you expect it.

But if you always have a featured event in the future, then nothing to worry about :D

<h3 class='ipsType_reset ipsWidget_title'>Featured Events</h3>
<div class='ipsWidget_inner'>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half'>
	{{endif}}
	{{if !empty( $events ) }}
		{{$featuredevents = false;}}
		{{foreach $events as $event}}
			{{if $event->featured}}	
				{{$featuredevents = true;}}
			{{endif}}
		{{endforeach}}	
		{{if $featuredevents}}
			<ul class='ipsDataList ipsDataList_reducedSpacing'>
				{{foreach $events as $event}}
					{{if $event->featured}}
						<li class='ipsDataItem ipsClearfix'>
							<div class='ipsDataItem_icon cCalendar_date_overlay'>
								<time datetime='{$event->nextOccurrence( $today, 'startDate' )->mysqlDatetime()}' class='ipsCalendarDate'>
									<span class='ipsCalendarDate_month'>{$event->nextOccurrence( $today, 'startDate' )->monthNameShort}</span>
									<span class='ipsCalendarDate_date'>{$event->nextOccurrence( $today, 'startDate' )->mday}</span>
								</time>
							</div>
							<div class='ipsDataItem_main ipsType_break ipsContained'>
								{{if $event->container()->allow_comments && $orientation == 'vertical'}}
									<div class="ipsCommentCount ipsPos_right {{if $event->comments === 0}}ipsFaded{{endif}}" data-ipsTooltip title='{lang="replies_number" pluralize="$event->comments"}'>{expression="$event->comments"}</div>
								{{endif}}
								<a href="{$event->url()}" title='{lang="view_this_event" sprintf="$event->title"}'>{$event->title}</a><br>
								<strong class='ipsType_small'>
									{{if $event->nextOccurrence( $today, 'startDate' )}}
										{$event->nextOccurrence( $today, 'startDate' )->calendarDate()}{{if !$event->all_day}} {$event->nextOccurrence( $today, 'startDate' )->localeTime( FALSE )} {{endif}}
										{{if $event->nextOccurrence( $event->nextOccurrence( $today, 'startDate' ) ?: $today, 'endDate' ) }}
											{{if $orientation == 'vertical'}}<br>{{endif}}
											<span class='ipsType_light ipsType_unbold'>{lang="until"}</span>{{if $orientation == 'vertical'}}<br>{{endif}}
											{$event->nextOccurrence( $event->nextOccurrence( $today, 'startDate' ) ?: $today, 'endDate' )->calendarDate()}{{if !$event->all_day}} {$event->nextOccurrence( $event->nextOccurrence( $today, 'startDate' ) ?: $today, 'endDate' )->localeTime( FALSE )}{{endif}}
										{{endif}}
									{{else}}
										{$event->lastOccurrence( 'startDate' )->calendarDate()}{{if !$event->all_day}} {$event->lastOccurrence( 'startDate' )->localeTime( FALSE )} {{endif}}
										{{if $event->lastOccurrence( 'endDate' ) }}
											{{if $orientation == 'vertical'}}<br>{{endif}}
											<span class='ipsType_light ipsType_unbold'>{lang="until"}</span>{{if $orientation == 'vertical'}}<br>{{endif}}
											{$event->lastOccurrence( 'endDate' )->calendarDate()}{{if !$event->all_day}} {$event->lastOccurrence( 'endDate' )->localeTime( FALSE )}{{endif}}
										{{endif}}
									{{endif}}
								</strong>
								<br>
								{{if $event->container()->allow_comments && $orientation == 'horizontal'}}
									<span class="{{if $event->comments === 0}}ipsFaded{{endif}}" data-ipsTooltip title='{lang="replies_number" pluralize="$event->comments"}'><i class='fa fa-comment'></i> {expression="$event->comments"}</span>&nbsp;&nbsp;
								{{endif}}
								{{if $orientation == 'horizontal'}}
									<div class='ipsType_medium ipsType_richText' data-ipsTruncate data-ipsTruncate-type='remove' data-ipsTruncate-size='2 lines'>
										{$event->truncated()|raw}
									</div>
								{{endif}}
							</div>
						</li>
					{{endif}}
				{{endforeach}}
			</ul>
		{{endif}}
	{{else}}
		<div class='ipsType_light ipsPad_half ipsType_center'>{lang="no_upcoming_events"}</div>
	{{endif}}
	{{if $orientation == 'vertical'}}
		</div>
	{{endif}}
</div>

I'll see if I can come up with the same thing in a custom block, which we can then tweak to not display in the above situation.

Posted

Damn I didn't think of that - thank you.  I managed to strip it down even further:

<h3 class='ipsType_reset ipsWidget_title'>{lang="block_upcomingEvents"}</h3>
<div class='ipsWidget_inner'>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half'>
	{{endif}}
	{{if !empty( $events ) }}
		<ul class='ipsDataList ipsDataList_reducedSpacing'>
			{{foreach $events as $event}}
				{{if $event->featured}}
				...
				{{endif}}
			{{endforeach}}
		</ul>
	{{else}}
		<div class='ipsType_light ipsPad_half ipsType_center'>{lang="no_upcoming_events"}</div>
	{{endif}}
	{{if $orientation == 'vertical'}}
		</div>
	{{endif}}
</div>

You could actually just wrap the whole thing in another...

{{if !empty( $events ) }}
	...
{{endif}}

... which would effectively output nothing apart possibly some blank space.  Really grateful for your help - very much appreciated - and If you can get a custom block working then that would be great. Happy face now :lol:

Posted

Yeah but I put in the little look for $featuredevents to avoid it doing an unnecessary <ul></ul> tag...but if you then wrap it up in that further code, and output nothing then all good. As I said though....it was to get your started. Ultimately, your choice what code goes in there.

Will see what I can do with a custom block though.

Posted
9 minutes ago, Nathan Explosion said:

Yeah but I put in the little look for $featuredevents to avoid it doing an unnecessary <ul></ul> tag...but if you then wrap it up in that further code, and output nothing then all good. As I said though....it was to get your started. Ultimately, your choice what code goes in there.

Will see what I can do with a custom block though.

Good point about the <ul></ul> tag. Is there any documentation on the various attributes for each class?  I was looking at getting at event_featured from the database but it is presumably getting loaded as $event->featured

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...