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) »
  • Putting CiviCRM Event Info in a Drupal Block
Pages: [1]

Author Topic: Putting CiviCRM Event Info in a Drupal Block  (Read 1788 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
Putting CiviCRM Event Info in a Drupal Block
March 16, 2010, 08:22:36 am
Hello,

I have been using the civicrm_eventblock module that is supposed to list the first (soonest) ten civicrm events in a Drupal block, but it has inexplicably stopped working properly, so I'm giving up on it.

I have tested the following by replacing Icalendar.tpl with this code (which condenses the events info) and it works.

Code: [Select]
{foreach from=$events key=uid item=event}
    {if $event.start_date}{$event.start_date|crmDate}{if $event.end_date}&nbsp;<em>{ts}to{/ts}</em>&nbsp;{strip}
                {* Only show end time if end date = start date *}
                {if $event.end_date|date_format:"%Y%m%d" == $event.start_date|date_format:"%Y%m%d"}
                    {$event.end_date|date_format:"%I:%M %p"}
                {else}
                    {$event.end_date|crmDate}
                {/if}{/strip}{/if}
        {else}{ts}(not available){/ts}{/if}<br />
    {if $event.event_type}{$event.event_type}{else}&nbsp;{/if}<br />
    <a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}" title="{ts}read more{/ts}"><strong>{$event.title}</strong></a><br />
    <a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event.event_id`"}">Read more...</a><br /><br />
    {/foreach}

Two questions for you coders (I don't consider myself much of a coder):

1) How would I write php code for a Drupal block to make this data appear in the block?

2) Can code be added to a) limit the listing to the ten soonest events or b) insert a pager within the block? If so, what would the finished code look like?

Thanks for your help.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Putting CiviCRM Event Info in a Drupal Block
March 18, 2010, 07:07:51 am
Hi there,

Have you considered using Drupal's view's module to acheive the same?  I did so for this website http://stethelburgas.org.

If you don't consider yourself much of a coder, it is probably the right way to go.  Views in configurable through the UI (no coding required, and it will do things like allow you to easily do things like add a pager, filter so you only see the next 10 events, etc.

You'll need to install views in Drupal and add a few lines to drupal's settings.php to allow it to see civicrm's tables, but once you've done that, the sky's the limit :)
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

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: Putting CiviCRM Event Info in a Drupal Block
March 18, 2010, 07:31:36 am
Thank you. I had been thinking of that. I've played with views some-- it's also a mind bender for me, but I'll give it a try. Can you be more specific about what I need to add to settings.php to allow Drupal/Views to see CiviCRM tables?

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Putting CiviCRM Event Info in a Drupal Block
March 20, 2010, 09:28:31 am
Had a look in the wiki but couldn't find it.  As someone that is doing it for the first time, it would a great thing for you to add to the documentation.

The basic idea is that you have to tell drupal where it can find the civicrm tables so you add some lines to your settings.php that look like this

Code: [Select]

$db_prefix = array(
  'civicrm_acl'                              => 'your_civicrm_database_name',
  'civicrm_acl_cache'                        => 'your_civicrm_database_name',
  'civicrm_acl_entity_role'                  => 'your_civicrm_database_name',
  'civicrm_activity'                         => 'your_civicrm_database_name',
  'civicrm_activity_assignment'              => 'your_civicrm_database_name',
  'civicrm_activity_target'                  => 'your_civicrm_database_name',
  'civicrm_address'                          => 'your_civicrm_database_name',
  'civicrm_cache'                            => 'your_civicrm_database_name',
  'civicrm_case'                             => 'your_civicrm_database_name',

...

  'civicrm_uf_match'                         => 'your_civicrm_database_name',
  'civicrm_worldregion'                      => 'your_civicrm_database_name',
);


replacing your_civicrm_database_name with, you've guessed it, the name of your civicrm database.

Does that help?
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Putting CiviCRM Event Info in a Drupal Block
March 20, 2010, 01:43:08 pm
You also need to include what the default is in the array

eg.


Code: [Select]
$db_prefix = array(
  'default'                                  => 'main_',
 'authmap'                               => 'ssodb.main_',
  'civicrm_acl'                            => civicrm_
etc

in this e.g the main drupal install is in tables like

main_nodes

some tables are being accessed from another db for single signon where the prefix main is also used

ie. ssodb.main_authmap

and the civicrm tables are prefixed by civicrm

ie. civicrm_acl
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Putting CiviCRM Event Info in a Drupal Block

This forum was archived on 2017-11-26.