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) »
  • Custom Standalone Screen for Event
Pages: [1]

Author Topic: Custom Standalone Screen for Event  (Read 7918 times)

jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Custom Standalone Screen for Event
May 22, 2013, 08:23:29 am
How would I take an existing template for custom fields based on CRM/Custom/Form/CustomData.tpl, do some reformatting,  add some read-only information at the top identifying the event, and use it as a standalone form?

Here are my thoughts on using it. I could find the appropriate event id using jquery to filter and populate a select box with events from which the user would select the event. Then I  could use jquery to call/redirect to the event form. I would like to display the custom form without showing the surrounding event information that you find when going through Events > Manage Events > ... > Info and Setting sequence.

It is not a permissions issue. The user would have admin access. The purpose is to simplify access to a few custom fields that could change multiple times in the event workflow.


jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: Custom Standalone Screen for Event
May 22, 2013, 12:43:56 pm
I have come aware of event templates since my previous post. Does the creation of an event template enable the creation of  a separate smarty template that is linked to the event template named under Events > Event Templates?  Perhaps that would work for me. I have used profiles where the profile id becomes the directory name under CRM/Profile/Form. I have create a tpl file in CRM/Profile/Form/31 for example. Is there a similar arrangement for an event tpl file called that is linked to the event template I create in Events > Event Templates?

I could probably wrap the CRM/Event/Form/ManageEvent/EventInfo.tpl in an if - else statement and include my custom tpl file in the if clause based on a variable I assign to the form in a hook (if the buildForm hook is called for events or if there is another hook available). Is that a good approach or is there a better way? I suppose an identifier of the event template would be available in the data passed to the hook.

Jere

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Custom Standalone Screen for Event
May 23, 2013, 10:03:22 am
FYI - If you are using Drupal and want to go a different route you can also use http://drupal.org/project/webform_civicrm .

jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: Custom Standalone Screen for Event
May 23, 2013, 10:15:21 am

Thanks, sonicthoughts. I will check it out.

jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: Custom Standalone Screen for Event
May 23, 2013, 10:10:14 pm
The webform-civicrm didn't work. It only gives access to contacts and not event data fields.

I did find a way, though, to get what I need. As a test I created a very simple api I called EventRecords.php that I put in my custom php directory under api/v3/:

Code: [Select]
function civicrm_api3_event_records_get($params) {
  return $_GET;
}

Thanks to http://wiki.civicrm.org/confluence/display/CRMDOC43/How+to+migrate+or+write+an+api.

In EventInfo.tpl file (my-custom-template-directory/CRM/Event/Form/ManageEvent/EventInfo.tpl) I added these lines at the top as a test:
Code: [Select]
{crmAPI entity="EventRecords" action="get" var="myData"}
{foreach from=$myData key=getkey item=getvalue}
  <div>{$getkey} : {$getvalue}</div>
{/foreach}

And it worked. It displayed all the values of the $_GET array:
reset : 1
action : update
snippet : 4
id : 9
qfKey : 48006f8ba3f46a273acd264030fa9f13_2305
component : event
q : civicrm/event/manage/settings

I am still pretty new to civicrm, and I did not see a way to write a profile-like custom screen I could call from a link without exposing the $_GET array to either a hook or to the smarty template. The only way I knew to do this is using the $form->assign from a hook (without modifying the core php files). It appears this approach lets me use the api functionality from the smarty template as a kind of hook that could retrieve things, do logic, call api's, and even executeQuery (if necessary) in php and send the results in an array back to the smarty template.

I am hoping the standard functionality of civicrm will handle the updates if I am only using custom fields linked to an event. If not, I could use a standard api for that or I could include an update function in the EventRecords.php as well and call either from a javascript/crmAPI function.

I know it is a hack. If someone sees a better way or a problem I haven't seen let me know.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Custom Standalone Screen for Event
May 23, 2013, 11:17:04 pm
Hi,

I'm not sure I understood why you need to display the get like that (I'm assuming it's a proof of concept), but never display a GET (or any user provided data) without filtering it first. It'd be trivial to abuse and use to hack a way in your installation.

If the aim it to put, say the id of an event, you need to be sure it's an integer before using it.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: Custom Standalone Screen for Event
May 24, 2013, 06:26:03 am
I have no intention of actually displaying the $_GET in an actual program. It doesn't work anyway. The $_GET is almost the same, but the extra parameter gets lost, or it is not the same $_GET.

I am not sure how I will do it yet, but I will keep plugging. Perhaps I can attach the custom fields the user wants to a contact type that has admin access. The form is used only by a person with administrator access who manages multiple events and wants a simple form with just the few fields she uses for tracking the status of an event and making notes about issues that arise. I would need a multiple-row custom data, one row for each event with a custom field to hold the event id to link to it. Then I could use the profile and hooks to do what I want.

Thanks for the alert to security.

« Last Edit: May 24, 2013, 09:46:17 am by jere »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Custom Standalone Screen for Event
May 28, 2013, 10:44:20 pm
Hi,

What eileen did was to create a report and edit in place to change values of an event (if I recall if was to change the estimate number of participants to see the budget impact).

Might be something you can use directly or build upon? install the advanced report extension see if it can help you.

Could you explain what is the use case? you have describing various technical options to implement it, but not sure I understand what is the (non technical) aim

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jere

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.31
  • PHP version: 5.3.10
Re: Custom Standalone Screen for Event
May 29, 2013, 01:31:54 pm
What are you referring to about what Eileen did? (update: I see)

I am building a site for a company that manages projects for other organizations. They do not yet do a front end for public participants; the events are either open or any admission and tracking of participants are handled by the other organizations. The participants in the database are only the few people per event who work on that event. However, they do many events a week and the people are scattered over a wide geographical range.

They are wanting a system for managing the people hired to do the events but are also interested in the future in handling more for events. I was familiar with civicrm but have been using it with some difficulty considering the extend of customization.

There are various reports screens for reporting by associates that are about the events: a report screen used prior to the event which for reportiong on preparations, one after the event which handles a recap, and one that is an upload of images and receipts with descriptions, etc. Each of the reports is one per associate assigned to the event, but that makes multiple rows for events.

To do this I attached the custom fields for those screens to the contact rather than the event, and then linked the row to the event using a field for the event id. I have managed to create the profiles and use the hooks to assign data, set defaults, and add elements to the templates. One involved multiple forms on one page because the report had events for which the custom fields were one row per event, and another on the form had values that were multiple rows for one event.

Those all worked fine, but now the manager wants one screen that she can use to see in one place the status of the events, whether reports have been filed, who has been assigned, and various other relevant bits of data. To do this I needed a profile for the event that pulls from custom data from multiple places. It became complicated, and although I have done a non-trivial amount of php coding, I am pretty new to civiCRM. Fortunately, Netbeans with xdebug lets me see and understand a lot about how civicrm is doing things that I don't find in documentation.

So my problem was how to create this custom screen. I was initially searching for a way to create a custom screen through a profile. But I could not create one for an event. My thought at the time of my last post was to use the api to create a screen that does everything through the ajax interface. I was thinking of piggybacking on the standard form for editing the event, but using the GET parameter to let the code decide whether to continue with the code for the existing edit, or include my custom template (using if..else../if in the smarty template).

That has not worked so well, so now I am trying to create a profile for an administrator subtype and using api calls or executeQuery to retrieve data from other custom data sets attached to other entities in a hook and create a profile, though attached to a contact, displays data for events. I add a couple of fields to a custom data set attached to the administrator subtype that has the event id that I can use to retrieve all the other information I need. I then will assign data to the template for the initial screen in the hook and use ajax to change the screen as the user selects filters. I am not sure how this will work. I am trying to use the CRM.api approach to api calls, but the javascript is not yet correct.

Thanks.
 
UPDATE: Maybe I don't have the include files to make the CRM.api work. What includes do I need?

Also, my reference to reports means the associates reporting about an event using a screen to input. The are not reports in the sense of outputting a report.

ANOTHER UPDATE: I found this: <script type="text/javascript" src="{$config->resourceBase}js/rest.js"></script> in Field.tpl and added it to the top of my custom tpl file.  It seems to have opened the way. The CRM.api style of api call works. I also don't need the $_GET variable since I am starting the custom screen from a profile and am (will be) calling the api in response to user input instead of a link.

I think I can get all I want with the standard api's with multiple calls and possibly using chaining (which I noticed but don't understand yet).
« Last Edit: May 29, 2013, 08:57:29 pm by jere »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Custom Standalone Screen for Event

This forum was archived on 2017-11-26.