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) »
  • Joomla hooks
Pages: [1]

Author Topic: Joomla hooks  (Read 1026 times)

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Joomla hooks
November 01, 2013, 03:20:52 am
Hi

I have been reading the manuals and have got so far but now am struggling.

I need to retrieve data from Virtuemart and insert it into a custom tab for Individuals and Organisations. I have got a tab but nothing on it (need to get smarty templates under my belt first), so thought I would try and enter data into a custom field, which I have set up on another tab.

I have added the hook file to the configuration and the hook file is being found. When I step through the code the process skips over my  joomla_civicrm_pre() function and nothing is changed on the custom field.

  • Am I using the correct function
  • There are 4 arguments for this function and I the only values I can find are in $_SESSION - I do not have all arguments
  • I also need Individual and Organisation -- can I leave out some of the arguments?


Here is the code I currently have
Code: [Select]
$contactId = $_SESSION['CiviCRM']['view.id'];

function joomla_civicrm_pre($contactId){   
    $customId = 6;
   
    $testtxt = 'test';
    $customParams = array("entityID" => $contactId, "custom_$customId" => $testtxt);
   
    require_once 'CRM/Core/BAO/CustomValueTable.php';
    CRM_Core_BAO_CustomValueTable::setValues( $customParams );
   
}



Thanks in advance

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: Joomla hooks
November 01, 2013, 08:14:32 am

1. I dont think so, you should check the hooks documentation. the pre/post hooks are called only for specific objects (not custom tables)

2. Check and use the relevant hook for custom fields

3. Yes, it is good practice to match the signature of the hook. Your pre code below does not match the signature and hence will not work as intended

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

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: Joomla hooks
November 05, 2013, 04:21:32 am
Ok thank you.

I am really struggling with trying to extract the relevant tasks I need to just retrieve data from Virtuemart (not interact with it). I am new to CiviCRM and have found masses of information but trying to get the bit/ bits that are relevant to my task is really difficult.  :'(     I am reading the manuals and trying to get the correct information. (http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference) Is there an overview of what is needed for the task I wish to complete, sorry for being a dumb blond.

I have now changed my function to joomla_civicrm_custom( $op, $groupID, $entityID, &$params ) but again when I load the page the function is bypassed.

I have looked at hook_civicrm_customFieldOptions - 'This hook is called when CiviCRM needs to edit/display a custom field with options (select, radio, checkbox, adv multiselect)'.  All I want to do is populate a custom text field, so I discarded this one.

I am spending a lot of time on trying to get a custom field filled when maybe I should be working on retrieving data from Virtuemart as I am getting nowhere fast.

I have had a look at the form hooks, do I need a form if all I am doing is displaying data from custom database tables? None of the descriptions on the functions I have looked at seem to fit my scenario.

I always find this when new to something that I 'miss' something crucial and end up going round in circles, I am getting rather dizzy now.

Could someone please, pretty please list the tasks and function I need to view data from Virtuemart on a tab (Got the tab working, Yippee).

Thanks




sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: Joomla hooks
November 05, 2013, 05:58:19 am
Hi

I have been having another look and I am going to try the tab and see if I can get the tab to display something.

Thanks

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: Joomla hooks
November 05, 2013, 08:45:00 am
Hi

I hope I am going down the right track.  I have tried several different functions (joomla_civicrm_custom, joomla_civicrm_post, joomla_civicrm_pre, looked at customFieldOptions) without much luck, the tabs - ( a Joomla plugin) is the only one that is being called. It also writes something when the Contact Summary page loads.

I have managed to get data retrieved and echo out onto the page using the tab hook. I have a custom tab and the only information I can find is in relation to editing files not creating new ones. I am not really sure this is the correct way to try and view fields on a tab from Virtuemart.

I have included a template page but the code is not displaying in the correct place, I have inspected the code and tried to find the correct classes and used these. I have added the custom template directory to the CiviCRM settings.  I am using  <div class="view-content"> but this is being displayed immediately underneath the <div id="m"> div and not under my Custom tab. Also I am viewing the Joomla menu in my tab  ???  how did that get there?

Can someone please tell me where I am going wrong, I am reading the documentation but I must be missing something crucial as I am not getting very far.

I know I am very trying but I am not finding what I need to progress, any help would be greatly appreciated. Just pointing me in the right direction would be a plus.  :)

Thank you


sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: Joomla hooks
November 06, 2013, 01:20:58 am
Having had some thoughts overnight I think I need an overview of how to set up a custom tab, so my questions so far are:

If I have a tab id => 'virtuemartTab' which is displayed in CiviCrm Joomla Administrator, what do I need for the following:
  • What do I need to do to create the URL that will 'point' to my content, are there any instructions for this or do I just inspect the current code? Do I need something like civicrm/custom/virtuemarttab/view
  • As I am using a 'custom' folder (This is included in CiviCRM settings), do I need to do anything to find the relevant file?
  • Am I missing anything else to make my code show my the tab, apart from a template file?


Thank you

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: Joomla hooks
November 06, 2013, 04:58:36 am
Following on from my last post this morning, I have found http://wiki.civicrm.org/confluence/display/CRMDOC41/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

This has a section at the bottom of the page that describes the file structure for the template overrides. I have followed this (these are Drupal instructions as I can't find anything for Joomla) and get some success in that I can write plain html from the template that shows in two places, right above the profile and when my custom tab is clicked twice. (I don't have any values assigned to the variables yet)

These are the steps I have taken:

Set the path for custom templates in CiviCRM
Make a custom version of CRM/Form/body.tpl at custom/templates/CRM/Form/body.tpl

Cut everything between the if $beginHookFormElements and /if

Create a new custom template at CRM/common called hookFormElements.tpl
Insert the $beginHookFormElements text from body.tpl


Place this snippet:
include file="CRM/common/hookFormElements.tpl"  (As my file has very little in it I cannot 'Include wherever body.tpl is also referenced')

Refresh the template files with &directoryCleanup=1 at the end of the url

my Tab URL is $url = CRM_Utils_System::url( 'civicrm/contact/view/virtuemartTab', "reset=1&snippet=1&force=1&cid=$contactID" );

I have included the hookFormElements.tpl in my template.

I have attached a screen shot as I am not sure my description is clear enough.


Thanks in advance for any guidance or pointing me in the right direction.  :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Joomla hooks

This forum was archived on 2017-11-26.