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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Change Drupal theme for just one event
Pages: [1]

Author Topic: Change Drupal theme for just one event  (Read 915 times)

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Change Drupal theme for just one event
January 31, 2012, 01:50:59 pm
Not sure where to put this post on the forums, so I'll put it here...

We want to switch to a particular Drupal theme for just one particular civicrm event. This means for the event info page, the event registration page, the confirmation page for the event, etc.

Drupal 7 comes with a lovely little hook called hook_custom_theme() which allows us to swap themes for particular pages according to arbitrary conditions, so I initially had a go at it like this (the event id is 8 in this case):

Quote
function tidbits_custom_theme() {
  if (strpos($_GET['q'], 'civicrm/event') !== FALSE && $_GET['id'] == 8 ) { 
      return 'our_custom_theme';
  }
}

And this works for the event info and register pages. But subsequent to that, civicrm switches the url to no longer inclue the event id in the query string, and instead uses a ghastly guickform key. I hopefully checked the POST parameters as well, hoping that that the event id may have been submitted as a hidden field, but also no luck. Without this id value, I can no longer identify which event the current page relates to.

Does anyone know how I can identify from within this hook whether I am currently on an event pages belonging to event id x?
« Last Edit: January 31, 2012, 01:52:38 pm by torrance123 »

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Change Drupal theme for just one event
January 31, 2012, 02:27:44 pm
I managed to solve this. For whatever reason, civicrm decides to start storing the event id the page is currently displaying in the session storage halfway through the event registration process. So this code works for my use case:


Code: [Select]
function tidbits_custom_theme() {
  if (strpos($_GET['q'], 'civicrm/event') !== FALSE) {
      if (!empty($_GET['id'])) {
          $id = $_GET['id'];
      }
      elseif (!empty($_GET['qfKey'])
        && !empty($_SESSION['CiviCRM'])
        && !empty($_SESSION['CiviCRM']['CRM_Event_Page_EventInfo'])
        && !empty($_SESSION['CiviCRM']['CRM_Event_Page_EventInfo']['id'])) {
          $id = $_SESSION['CiviCRM']['CRM_Event_Page_EventInfo']['id'];
      }
      else $id = FALSE;
           
      if ($id == 8) {
        return 'garland';
      }
  }
}
« Last Edit: January 31, 2012, 02:29:35 pm by torrance123 »

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Change Drupal theme for just one event
May 17, 2012, 07:38:58 pm
I'm back on this issue: still trying to set change the theme for a single set of event registration pages.

The issue is not how to *change* the theme, but how to recognise when we're on a page for a particular event. As I mentioned in the original post here, it's easy enough to pull the event id from the GET query on the first page, but all subsequent pages don't have this id available. Last time, I discovered the id moved into the $_SESSION array on the subsequent pages, but now a few months down the track and a civicrm update appears to have changed that behaviour.

How can I recognise that I'm on a particular set of event registration pages? Where can I learn the event ID?

If it helps, this is the global info I *do* have available to me:

The $_SESSION array

Code: [Select]
CiviCRM (Array, 11 elements)
defaultWysiwygEditor (String, 1 characters ) 2
qfPrivateKey (String, 64 characters ) ca07deae2e158c6f25bf6d63dcac9a9596358c5131ad8d0...
qfSessionID (String, 43 characters ) KwanlK6wBfff23BYit0fCS-VhU64lVQPDG2eHvk6a6w
ufID (String, 1 characters ) 4
userID (String, 1 characters ) 4
ufUniqID (String, 0 characters )
CRM_Utils_Recent (Array, 1 element)
0 (Array, 11 elements)
CRM_Profile_Page_Dynamic (Array, 0 elements)
CRM_Contribute_Page_ContributionPage (Array, 1 element)
action (Integer) 16
CRM_Event_Page_ManageEvent (Array, 1 element)
action (Integer) 16
userContext (Array, 1 element)
0 (String, 29 characters ) /civicrm/event/manage?reset=1

The $_POST array:

Code: [Select]
qfKey (String, 37 characters ) 8bc6f1403f7hgfdhdf81741531cefd1d35927fd_2678
scriptFee (String, 0 characters )
scriptArray (String, 0 characters )
priceSetId (String, 1 characters ) 5
_qf_default (String, 15 characters ) Register:upload
MAX_FILE_SIZE (String, 9 characters ) 104857600
additional_participants (String, 0 characters )
is_pay_later (String, 1 characters ) 1
email-5 (String, 21 characters ) xxxxxxx@fuzion.co.nz
first_name (String, 4 characters ) Test
last_name (String, 4 characters ) Test
phone-Primary-1 (String, 8 characters ) 12345678
phone-Primary-2 (String, 0 characters )
custom_7 (String, 0 characters )
custom_29 (String, 0 characters )
custom_30 (String, 0 characters )
custom_33 (String, 0 characters )
credit_card_type (String, 0 characters )
credit_card_number (String, 0 characters )
cvv2 (String, 0 characters )
credit_card_exp_date (Array, 2 elements)
billing_first_name (String, 3 characters ) gfg
billing_middle_name (String, 0 characters )
billing_last_name (String, 7 characters ) gjhkgjk
billing_street_address-5 (String, 0 characters )
billing_city-5 (String, 0 characters )
billing_country_id-5 (String, 4 characters ) 1228
billing_state_province_id-5 (String, 0 characters )
billing_postal_code-5 (String, 0 characters )
_qf_Register_upload (String, 11 characters ) Continue >>

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Change Drupal theme for just one event

This forum was archived on 2017-11-26.