Question

I'm trying to figure out how to properly format the following site's pages: http://marchofremembrancehouston.org/march/?page=CiviCRM&q=civicrm/event/register&reset=1&id=25

See how the CiviCRM data is pushed to the top right of the site? I would like the form to fit inside the content area of the theme.

I've already done a lot of research and no one seemed to give a clear answer.

Was it helpful?

Solution

This is a bug in CiviCRM. You're using a WordPress plugin that processes each page's content to create tags for Facebook Open Graph (to populate the blurb and image that goes on your Facebook post when you share the page). The problem is that processing the content triggers CiviCRM to run, and consequently, it prints all the content in the head of the page.

The issue describing this in a little more depth is here: https://issues.civicrm.org/jira/browse/CRM-14244

The next release of CiviCRM (4.4.5) will contain the fix, but if you're in a hurry to publish the page, here's what you can do:

  1. Go in the files of your site to wp-content/plugins/civicrm/civicrm.php

  2. Scroll down to line 412 or so (depending upon your version) and look for the line saying

    public function invoke() {
    
  3. Add the following lines below it:

    if ( !in_the_loop() && !is_admin() && empty($_REQUEST['snippet']) ) {
      return;
    }
    

    What that says is, if you aren't displaying the main content of the page (running "The Loop"), showing an admin page, or displaying a "snippet" (CiviCRM content that belongs within another page), go back and do nothing. CiviCRM will be invoked again when it's the time to run the actual page content.

For reference, the pull request I made in GitHub to handle this is at https://github.com/civicrm/civicrm-wordpress/pull/36/files, where you can see the end result.

If you're in CiviCRM 4.3 or earlier, you'll want to add those lines to the function civicrm_wp_invoke, inserting them after the following (at or near line 292):

function civicrm_wp_invoke() {

OTHER TIPS

This fix is not complete and breaks chain loading AJAX queries within CiviCRM, e.g. for retrieving state dropdown lists if a country is picked in CiviProfiles. The actual fix should check for this:

if ( !in_the_loop() && !is_admin() && empty($_REQUEST['snippet']) && ($_REQUEST['q'] != "civicrm/ajax/jqState") ) {
    return;
}

NOTE: this is not yet fixed in 4.4.5 but adding the above line to wp-content/plugins/civicrm/civicrm.php should allow for the state selection to start working again, otherwise you'll also notice a nasty JavaScript error since the returned value is HTML, but the ajax call expects JSON. Why this sort of bug is not caught and fixed prior to release in a simple automated test, to this day I do not understand.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top