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 (Moderator: Donald Lobo) »
  • Create PCP after registering for event
Pages: [1] 2

Author Topic: Create PCP after registering for event  (Read 2707 times)

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Create PCP after registering for event
May 13, 2011, 09:08:12 am
I'm currently working on a project which requires automatic creation of the PCP when the registration for the event has been submitted. I don’t think it’s possible with the standard CiviCRM features so I’ve started modifying the code and so far I have functionality to assign the Contribution Page to the Event. Now, I need to modify the registration process, so when someone submits the registration form, the PCP is being automatically created. Could someone give me some tips what will be the easiest way to achieve it?  Also, is it nessesary to create a Contact when the PCP is created or can I turn it off somehow? Thanks a lot!

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: Create PCP after registering for event
May 13, 2011, 09:40:20 am

1. use the postProcess hook to create the PCP

2. yes, u need a contact id to create a PCP

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

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 13, 2011, 04:05:50 pm
Thanks Lobo. Trying to do it now but for some reason hooks don't work for me at all. I started debugging it and it looks like the civicrmHooks.php file is not being included (CiviCRM 4.0 on Joomla 1.6)

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: Create PCP after registering for event
May 13, 2011, 06:27:16 pm

for 4.0 / J1.6, we've switched to using joomla plugins and events for civicrm hooks. I've asked elin who wrote the code to answer in more detail and also help with the documentation

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

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Create PCP after registering for event
May 14, 2011, 04:01:59 am
The way plugins work in Joomla is that they respond to specific events/triggers. You use those to call in the hooks.

http://docs.joomla.org/Plugin  is a place to read more about how plugins work.

So there are two things you can do with plugins, one is what you want which is to incorporate a hook while you are in the civicrm context. The other is to respond to a Joomla event and do something like put a profile in an article or put  the contact id in the user object.

In terms of hooks, what you want to do is have a civicrm plugin by which I mean we want a plugin that is going to be available when we are in the com_civicrm context (based on the url).

Lobo and I actually have a bunch of example plugins for this but they all follow the same logic.

Here's the code for adding to summary

summary.php has this:

<?php
/**
 * @version      
 * @package      Civicrm
 * @subpackage   Joomla Plugin
 * @copyright   Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license      GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access
defined('_JEXEC') or die;

jimport('joomla.plugin.plugin');
class plgCivicrmSummary extends JPlugin
{

/**
 * Example Civicrm Plugin
 *
 * @package      Civicrm
 * @subpackage   Joomla plugins
 * @since      1.5
 */
   public function civicrm_summary($contactID, &$content, &$contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW)
   {
    $contentPlacement = $this->params->def('placement');
    $content = "
      <table>
      <tr><th>Hook Data</th></tr>
      <tr><td>Data 1</td></tr>
      <tr><td>Data 2</td></tr>
      </table>
      ";
   }
}

and the xml has this:

<?xml version="1.0" encoding="UTF-8"?>
<extension version="1.6" type="plugin" group="civicrm">
   <name>plg_civcrm_summary</name>
   <author>Joomla! Project</author>
   <creationDate>November 2005</creationDate>
   <copyright>Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.</copyright>
   <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
   <authorEmail>admin@joomla.org</authorEmail>
   <authorUrl>www.joomla.org</authorUrl>
   <version>1.6.0</version>
   <description>PLG_CIVICRMSUMMARY_XML_DESCRIPTION</description>
   <files>
      <filename plugin="summary">summary.php</filename>
      <filename>index.html</filename>
   </files>
   <config>
         <fields name="params">
         <fieldset name="basic">
            <field name="placement"
               type="list"
               default="1"
               description="PLG_CIVICRM__JOOMLA_FIELD_CHECK_CATEGORIES_DESC"
               label="PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_LABEL">
               <option value="1">After</option>
               <option value="2">Before</option>
               <option value="3">Replace</option>               
            </field>

         </fieldset>
      </fields>

   </config>
   </extension>

Which gives you an option to put it after, before or instead of ... but you don't need to do that it's just there as an example and in a specific  site of course you would to one or the other. That's just really to show how to use a parameter.





 And the great thing is you can have as many as you want, you can put conditionals in, and so on.

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Create PCP after registering for event
May 14, 2011, 05:37:38 am
Just thought about it, andd of you didn't do the parameter of  course you could put both before and after in the plugin if you wanted.

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 05:55:52 am
Thanks for that. Is there any documentation for this available? If not, could you give me some more details e.g. where to put the plugin files? Should it be in /plugins/civicrm/plgName/plgName.php?

Also, what is the naming covention now? I need to implement the buildForm and postProcess hooks.
« Last Edit: May 14, 2011, 06:11:10 am by peter »

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 06:11:18 am
Ok, I've just found it in the administrator/components/com_civicrm/civicrm/joomla/plugins but still can't make it work. Do I need to enable the plugin somehow?

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 08:37:55 am
anyone?

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: Create PCP after registering for event
May 14, 2011, 09:57:45 am
Did you install it?  Once you install it you need to enable it. Just like any Joomla plugin.

The group should be civicrm.

Just like any plugin you can either use the installer or you can put the files into position and then use the discover install method.

So the proper location in 1.6 would be
joomlaroot/plugins/civicrm/pluginname/ and then put the two files (or more if for some reason you need more such as a language folder).

Remember that Joomla is strongly convention driven which means you need to follow the naming patterns.
plgCivicrmSummary
Indicates the civicrm group, summary plugin.

<filename plugin="summary">summary.php</filename>

Shows the name of the base file (summary.php) and the name of the plugin (summary).




peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 10:04:42 am
Thanks mcsmom, I've figured it out 5 minutes ago - had a wrong filename an Joomla dicover couldn't find it. Thanks again, I might have more questions later :)

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 11:12:23 am
Still can't make it work. I've added, installed and enabled the plugin in the civicrm group, added function civicrm_buildform to test it, but it still doesn't work...

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 01:07:51 pm
Still nothing. I've started debugging the dispatcher and it looks like the events from my plugin are not there. Here is what I did so far:

- created folder joomla_root/plugins/civicrm/plgCiviCRMHooks and added following files to it: plgCiviCRMHooks.php & plgCiviCRMHooks.xml
- the plgCiviCRMHooks.php contains the plgCiviCRMHooks class (extending JPlugin) with the civicrm_buildForm method
- plugin has been installed and enabled in joomla but it looks like the civicrm_buildForm isn't being called when I open the registration form

any suggestions?

peter

  • I’m new here
  • *
  • Posts: 23
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Joomla
  • MySQL version: 5
  • PHP version: 5
Re: Create PCP after registering for event
May 14, 2011, 05:14:04 pm
Ok, finally got it working after reading updated hook specification :) - I probably had some naming problem. Maybe this will help someone else - my plugin will contain all the form related hooks:
- class name: plgCivicrmForm
- files: joomla_root/plugins/civicrm/form/form.php & joomla_root/plugins/civicrm/form/form.xml

Now, I can finally start working on the business logic :)

One more question - is it possible to add an extension which will add another tab with form  to the Event details screen in the CiviCRM backend? I did that already by changing the CiviCRM code, but if it's possible I'd like to move it out of the core and use plugin.

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: Create PCP after registering for event
May 15, 2011, 08:54:38 am
Quote from: peter on May 14, 2011, 05:14:04 pm
One more question - is it possible to add an extension which will add another tab with form  to the Event details screen in the CiviCRM backend? I did that already by changing the CiviCRM code, but if it's possible I'd like to move it out of the core and use plugin.

can u explain a bit more on what you want to do and why? I dont think its possible now since we did not have anyone needing it, but potentially can create a hook that will enable this

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] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Create PCP after registering for event

This forum was archived on 2017-11-26.