CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • How to Modify Core Upcoming Events Block to Include Event Type
Pages: [1]

Author Topic: How to Modify Core Upcoming Events Block to Include Event Type  (Read 2000 times)

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
How to Modify Core Upcoming Events Block to Include Event Type
March 18, 2010, 08:07:17 am
This relates to my earlier post
http://forum.civicrm.org/index.php/topic,12802.0.html
about getting upcoming events to list in a sidebar block, but is different enough to warrant a separate post IMO.

I could possibly use the "CiviCRM Upcoming Events" that is part of the CiviCRM core. Looking at the template file for this block, I see that it is somewhat customizable:

Code: [Select]
{* Block to display upcoming events. *}
{* You can add the following additional event elements to this tpl as needed: $ev.end_date, $ev.location, $ev.description, $ev.contact_email *}
{* Change truncate:80 to a larger or smaller value to show more or less of the summary. Remove it to show complete summary. *}
<div id="crm-event-block">
{foreach from=$eventBlock item=ev}
    <p>
    <a href="{$ev.url}">{$ev.title}</a><br />
    {$ev.start_date|truncate:10:""|crmDate}<br />
    {assign var=evSummary value=$ev.summary|truncate:80:""}
    <em>{$evSummary}{if $ev.summary|count_characters:true GT 80}  (<a href="{$ev.url}">{ts}more{/ts}...</a>){/if}</em>
    </p>
{/foreach}
</div>

However, I need to include the event type in the listing and event type is not one of the parameters that this block has configured as an option.

I'd like to know if I could modify the php somewhere so that event type is included in the eventBlock array so I could add it to the display.

To see what I mean, you could visit my page
www.peachlocal.com
You will see two versions of an upcoming events block in the left sidebar. The upper one is generated by a slightly modified version of the third-party civicrm_eventblock module for Drupal that does include the event type. The event type appears in bold, such as "Potluck" and "Farm Camp Session". I like this display, but the module is malfunctioning and has stopped displaying new events, so I'm giving up on it.

If you scroll down you'll see another upcoming events block that is generated by a slightly modified version of the core "CiviCRM Upcoming Events" block. I like this because it works-- it lists all the events properly and is easily customized but lacks the event type, does not limit the number of events displayed and is not paged.

So...

1) Again, how would I go about getting the event type to display using the core "CiviCRM Upcoming Events" block?

2) What code could be added to the template for the core "CiviCRM Upcoming Events" block that would display only the first ten events? Although not crucial, what code might be added to allow for a pager? Could code be written to display the next ten events in the same block? Would this accomplished through some standard modification of the "foreach" command?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How to Modify Core Upcoming Events Block to Include Event Type
March 18, 2010, 08:59:12 am

assuming u r familiar with PHP/MySQL your best bet would be to:

1. Modify and potentially integrate the changes from the drupal module to the civicrm block code

2. the civicrm block code is here:

CRM/Core/Block.php, function setTemplateEventValues

the function getCompleteInfo can take an eventType, so you can use that to filter

3. You might want to add a link to All Events which basically takes you to the page (or view) of all the current and upcoming events, something like:

http://civicrm.org/civicrm/event/ical?reset=1&page=1&html=1

This will avoid trying to build a pager within the block.

Alternatively you might be able to do all of the above via the views2 integration. Please do report back :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
Re: How to Modify Core Upcoming Events Block to Include Event Type
March 23, 2010, 07:39:46 am
The civicrm upcoming events block template is at templates/CRM/Block and called Event.tpl. It's controlled by CRM/Core/Block.php which in turn calls upon an array that is defined in CRM/Event/BAO/Event.php.

The Event.tpl file says

"You can add the following additional event elements to this tpl as needed: $ev.end_date, $ev.location, $ev.description, $ev.contact_email", but there are more, potentially useful event elements available than have been identified in the preceeding list since they are also part of the array. The complete list is as follows:

Code: [Select]
ev.title
ev.event_id
ev.summary
ev.description
ev.start_date
ev.end_date
ev.contact_email
ev.event_type
ev.is_show_location
ev.is_online_registration
ev.registration_link_text
ev.registration_start_date
ev.registration_end_date
ev.url
ev.location (is a sub-array called "$address" consisting of the following

 
            $address = '';

            $addrFields = array(
                                'address_name'           => $dao->address_name,
                                'street_address'         => $dao->street_address,
                                'supplemental_address_1' => $dao->supplemental_address_1,
                                'supplemental_address_2' => $dao->supplemental_address_2,
                                'city'                   => $dao->city,
                                'state_province'         => $dao->state,
                                'postal_code'            => $dao->postal_code,
                                'postal_code_suffix'     => $dao->postal_code_suffix,
                                'country'                => $dao->country,
                                'county'                 => null
                                );           

So, I changed the original Event.tpl:

Code: [Select]
<div id="crm-event-block">
{foreach from=$eventBlock item=ev}
    <p>
    <a href="{$ev.url}">{$ev.title}</a><br />
    {$ev.start_date|truncate:10:""|crmDate}<br />
    {assign var=evSummary value=$ev.summary|truncate:80:""}
    <em>{$evSummary}{if $ev.summary|count_characters:true GT 80}  (<a href="{$ev.url}">{ts}more{/ts}...</a>){/if}</em>
    </p>
{/foreach}
</div>

to this (so that the event type is displayed):

Code: [Select]
<div id="crm-event-block">
{foreach from=$eventBlock item=ev}
    <p>
    {$ev.start_date|truncate:10:""|crmDate}<br />
    <strong>{$ev.event_type}</strong><br />
    {$ev.title}<br />
    <a href="{$ev.url}">More Info...</a><br /><span><hr style="height: 2px; width: 100%;" color="#f19f0f"></span>
   
    </p>
{/foreach}
</div>

This displays ALL upcoming events. I'd still like to hear ideas about how I might limit this to, say, the next ten events or include a pager in the block, but it works for me now. It's farming season, so it won't probably be until winter when I will have a chance to try this using Views2.

Tolk

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Re: How to Modify Core Upcoming Events Block to Include Event Type
April 24, 2010, 01:24:32 pm
Quote from: farmrchrys on March 23, 2010, 07:39:46 am
The complete list is as follows:

Code: [Select]
ev.title
ev.event_id
ev.summary
ev.description
ev.start_date
ev.end_date
ev.contact_email
ev.event_type
ev.is_show_location
ev.is_online_registration
ev.registration_link_text
ev.registration_start_date
ev.registration_end_date
ev.url
ev.location (is a sub-array called "$address" consisting of the following

 
            $address = '';

            $addrFields = array(
                                'address_name'           => $dao->address_name,
                                'street_address'         => $dao->street_address,
                                'supplemental_address_1' => $dao->supplemental_address_1,
                                'supplemental_address_2' => $dao->supplemental_address_2,
                                'city'                   => $dao->city,
                                'state_province'         => $dao->state,
                                'postal_code'            => $dao->postal_code,
                                'postal_code_suffix'     => $dao->postal_code_suffix,
                                'country'                => $dao->country,
                                'county'                 => null
                                );           


Is there any way to display the booking status (Event is full) there as well? It would be great if people could see right away if an event is already fully booked.

Thanks,
Tolk

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How to Modify Core Upcoming Events Block to Include Event Type
April 24, 2010, 06:50:37 pm

This should be possible with some code changes. Would be great if you can check and code and submit a patch. ping us on IRC if you need help getting started

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • How to Modify Core Upcoming Events Block to Include Event Type

This forum was archived on 2017-11-26.