I was trying to display event info using views (to replace the current event info) and realized that the fee is not present. I believe it used to be avail in standard views but can't seem to find. I see Fee label and Default Fee ID fields. I assume they are an index into other tables (Price sets?) Any suggestions on how to display?
Comments
Comment #1
sonicthoughts commentedI just saw this patch avail for views to add additional entities. Wonder if we could/should include for Civicrm Entity module?
New Feature Request:
Integrate price sets and price field data with Drupal Views.
Use Case:
Need to create event listings in Drupal using Views and that include information stored in price sets, such as registration fees and workshops.
Patch Info:
The attached patch adds a Price Set ID field to CiviCRM Events in Views.
In addition, it enables Views to be created on:
- CiviCRM Price Sets
- CiviCRM Price Fields
- CiviCRM Price Field Values
It includes a Views Relationship between CiviCRM Price Fields and CiviCRM Price Field Values to make it easier to retrieve all of the values for a price field.
Usage:
Typical usage would be to create a view on CiviCRM Price Set or CiviCRM Price Field and pass in a Price Set ID as a contextual filter. The Price Set ID can be obtained as a field on CiviCRM Events. A Views Relationship can be added between CiviCRM Price Fields and CiviCRM Price Field Values to retrieve all of the values for a price field.
Comment #2
eileenmcnaughton commentedthat patch will go in core - but no reason we can't enable those entities as CiviCRM entities - do you want to try & see what happens
You just need to add the extra entities in 2 places
https://github.com/eileenmcnaughton/civicrm_entity/blob/7.x-2.x/civicrm_...
https://github.com/eileenmcnaughton/civicrm_entity/blob/7.x-2.x/civicrm_...
& if you try that & say those entities should be enabled I'm happy to accept that as a patch / PR (or I can apply it if you aren't sure how to submit that way).
Note that we won't implement the relationship that way in civicrm entities - if we are going to implement more relationship we'll figure out a more generic way to do it
Comment #3
markusa commentedI did test PriceSets, PriceFields, and PriceFieldValues with civicrm entity 2.x and it works...at least as far as my limited testing went...
Comment #4
sonicthoughts commentedI tried to add the three bundles in both places, cleared cache, but I do not see any fields. I do see the entity, but no fields are listed. I also do not see in views. No error in watchdog. I assume the CamleCase was not a problem (perhaps not consistent.)
Comment #5
markusa commentedComment #6
sonicthoughts commentedOk, still some strange stuff going on (probably my error ...) Views does show the Entity/fields, but admin menu and entity display are "stuck" with the old values.
1. I changed the file as referenced above (duhh)
2. drush cc all
3. Tried to access priceset via direct entity edit form (ie. /civicrm-price_set/2 OR /admin/structure/types/manage/civicrm_price_set/display - page not found.
4. I tried drush rr (registry rebuild)
5. now the strange thing is that the old code: admin/structure/types/manage/civicrm_PriceSets still works (no fields though.) even though I changed the code as per above! I also see in admin menu|content types|Civicrm PriceSets
Could it be that the old whitelist is not being removed / cleaned up. I also tried to disable/re-enable the module (didn't try to remove it yet.)
Also (and more importantly), how do i make the relationship between event and price_set? Should this be done in the module (http://drupal.stackexchange.com/questions/64875/how-to-add-relationship-...) or using the Entity Reference Module ?
My goals is simply to include the fees for an event.
notes:
I tried to use both the github 2.x nov 29th and drupal 2.x dec2nd (are they the same?)
I also see a patch included in the distro: "full-working-crud-forms-drupal-fields-standard.patch" - is that meant to be run?
Thanks for your patience with me ...
Comment #7
markusa commentedThe patch file in the repo was probably just placed there as a diff to know what was changed...No need to run or apply that.
try: civicrm-price-set/1 , I've been replacing _ with - for the urls
I'm able to access Manage Display, and Manage fields for Price sets, without any additional effort...
As far as the views relationships go...that would have to be coded, and placed in an auxilary module.
I've been playing with it a little bit, but haven't gotten it to work yet....
There's two tables price_set and price_set_entity, and I haven't had success loading them both as entities, the code above inlcudes the data from the price_set table, not price_set_entity....but that is where the connection is made to events or contribution pages...
Comment #8
markusa commentedI don't think this is going into the CiviCRM Entities module...unless Eileen wants it...
Cobbled together a little module to get views relationships:
https://github.com/jackrabbithanna/civicrm_price_field_aux
So with a view that lists events:
Add new relationships to drill down to the Price Field Values:
CiviCRM Price Set Entities: Price Set
(Price Set) Price Field: Price Field
(Price Field) CiviCRM Price_field: Price Field Value
Comment #9
markusa commented@sonicthoughts:
I forgot, the code also needed some additions to include permissions for viewing/editing/deleteing price sets, price fields, and price field values...
You won't be able to get to those pages without that....
@eileen:
I've created a PR to include Price Sets, Price Fields, and Price field values, if you want that in the project...
@sonicthoughts:
working code for price entities here for now: https://github.com/jackrabbithanna/civicrm_entity
that will work with this: https://github.com/jackrabbithanna/civicrm_price_field_aux
Comment #10
eileenmcnaughton commentedI've merged the price set patch - re the joins patch - thoughts.
1) does it interact OK with the patched version of views that sonicthoughts referred to?
2) the join to event doesn't take into account the entity_table field
3) you seem to be declaring some things (field sortability etc) that ideally we could do more generically
4) join to civicrm_contribution changes between 4.4 & 4.5 (you aren't doing that join)
I'm inclined to leave it separate for now & see what things we can do in a generic way (e.g declare joins whereever we hit an FK or based on the pseudoconstants in the schema
Comment #11
markusa commentedI agree about the views, I put it into a separate module for that reason. I just put it up so sonicthoughts could get the functionality he wants right now. CiviCRM Entity should do its best to do things systematically, without specific views coding...
RE: the patch mentioned, for people running CiviCRM with that patch, (I assume its coming for 4.6) it would be unnecessary. If they are running an earlier version, well then people can use the little module...I don't think you'd want to do both at the same time.
The join doesn't take into account the entity_table, but it doesn't matter. That would only apply to Views that are lists of events anyway...it joins the id with the entity_id field, so for events, the price set data for that event will be available.
If we exposed contribution_pages, we could do some similar code for them....
Comment #12
sonicthoughts commentedHi guys - been doing some more testing (on 7.x-2.x-dev 12/7 release).
1. civicrm-price-set/1
generally works, but for some fields get: Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1583 of /home/xxxx/public_html/test/includes/bootstrap.inc).
2. Missing template files. Would it be possible to use a generic method for tpl files so we can add new entities w/out a patch? Get:
3.Recipie for exposing price fields (Mark, got a bit stuck showing multiple field values in price set.):
a. Install and enable the module: civicrm_price_field_aux
b. Add price template files if necessary (ie. copy modules/civicrm_entity/templates/civicrm-tag.tpl.php to civicrm-price-set.tpl.php php civicrm-price-field-value.tpl.php civicrm-price-field.tpl.php)
c. Add 2 new fields: CiviCRM Price Set Entities: Entity Table (Entity Table) and CiviCRM Price Set Entities: Price Set ID (Price Set ID)
d. Add relationships :first, CiviCRM Price Set Entities: Price Set, then (Price Set) Price Field: Price Field, then (Price Field) CiviCRM Price_field: Price Field Value
e. Add new related value fields (e.g. CiviCRM Price_field_value: Amount (Amount), (Price Field Value) price-field-val label (Label), etc.
I'm not sure why all the field values are not showing up - I have a few for each event.
note - got strange error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'help_post' in field list is ambiguous (also for other fields) unless I changed the administrative name - Guess some naming conflict.
So much for trying to do something simple :)
I think that showing linked event info is very important for anyone trying to use Drupal as a front end, but wonder if there is a way to get the whole thing rendered right from civicrm (like a location block) as a shortcut....
Also, is the module you created necessary or can it (should it) be accomplished with Entity Reference Fields? Frankly, the whole multi-level indirection is making my head spin a bit. Your a real rock star for helping out with this!
Comment #13
markusa commentedI forgot to add the template files in the the PR... :(
The little module I create was necessary to get the relationships so that you could show price_field_value data for events....One thing I noticed was that the event data would get listed for each price field value, so some usage of the Views Field View module might be appropriate.
Its the same as if you had nodes with a multi-valued term reference field, and you add a relationship to term data, if you have 2 term referenced on a node, the view will list the node twice.....
So when you say:
does that mean that some show up and some don't? I've done limited testing, enough to get a basic event pricing to work, didn't even try yet with more complicated price set pricing structures.
Well nothing worth doing is easy the first time :) Gotta crawl before we walk and what not.
I havent' experienced the SQL error you mentioned, but I've seen the:
for several entities, not just price set fields...
Can you provide details on what field values are not displaying? Types of fields, configuration, etc...
Shoot me an email or ping me on Google and we can schedule a short screen share so that I can look it over....
Comment #14
sonicthoughts commentedOld issue, but I just upgraded from 4.5.x to 4.6.2 and noticed that the Amount field in the PriceFieldValue entity is now including the currency symbol ($) however I'm trying to use a different currency. (It's actually a pain because the currency field is with the event not the priceset/pricefield.
Any idea why the $ is hard coded here? Could it know that it is a currency field and need drupal views to set it somehow???
Comment #15
markusa commentedclosing this issue....start a new issue with the latest comment if it still occurs
Comment #16
tstermitzI was able to get an Event Price to show up in an event views using Views Field View and contextual links using the Price Set ID. I followed this tutorial: https://www.ostraining.com/blog/drupal/views-field-view/ . You have to create your sub-view off "Price Fields", not Price Sets", although both of them have the Price Set ID in them.
I have a feeling this is not an efficient mechanism.
I don't understand why CiviCRM can't create a relationship between Event and Price Field entities?
Comment #17
markusa commenteddid you try this module:
https://github.com/jackrabbithanna/civicrm_price_field_aux
That should provide you the necessary relationships
Comment #18
Katy Jockelson commentedI know this is an old thread, but it's the only one I can find on this subject.
I am trying to set up a view to replace the individual event info page and I've got it working with a contextual filter in the URL, to show all fields except the priceset. I have tried markusa's module (gives me a broken handler when I try to add relationship). I'm just starting down the road of a view within a view as per the last comment here but I'm getting a bit lost, and before I go any further, I just wanted to check if it should be possible to add an event priceset to a view, without needing a secondary view. If yes, instructions would be really really helpful. Thank you!
Also noticed that when I add a relationship of 'CiviCRM Price Set Entities: Price Set' to the view and print the name (or, in fact, just print the priceset ID without the need for the relationship, unless I'm misunderstanding something here, then it's actually returning the wrong ID/priceset. I.e. not the one I've chosen for the event.
Comment #19
markusa commentedFor sure. Have the latest version of CiviCRM Entity (for Drupal 7)
Install both CiviCRM Entity and the submodule, CiviCRM Entity Views Extras
Here's the export code for a sample View, which is a list of events, but relates to the Price Set, then the Price Fields of the price set, and then the Price Field Values for the Price fields
Comment #20
Katy Jockelson commentedThank you so much. I've just seen this.
I am also trying to just print regular event fees and not seeing how to do that. Any advice on that?
Thanks a lot.
Comment #21
markusa commentedEven if you don't select a price set when creating an event, and just use "normal" or "regular" event fees, Civi still creates a price set with one price field, although it is hidden from the CiviCRM Price Set UI.
So you should be able to pull the prices from the price field values of the price field of the price set.
The "Fee label" that is required above the "Financial Type" field, populates the Price Field Label
The Fee Labels in the "Regular Fees" section match up to Price Field Value Label, and the Amounts match up to Price Field Value Amount
The Event title will be the Price Set Title
The View import code I posted would let you see these .. so same structure whether you use a custom price set or not.
Comment #22
Katy Jockelson commentedThank you @markusa. I will try this later and feedback.
Comment #23
Katy Jockelson commentedThanks for your help so far @markusa. I got the fee amounts and labels showing up. In case it's useful to others, I will write out the 2 other issues I encountered.
Comment #24
Katy Jockelson commentedEDIT: this comment no longer makes sense, as I've edited my comment (#23) above.
Ah, the reason that random price set entry #3 is showing up is because of my contextual filter being based on the raw value in the URL. It's adding in the price set for the contribution page that has the same ID as this event. So that's a whole side issue...
Comment #25
markusa commentedFor #24 you need to add a filter:
CiviCRM Price Set Entities: Entity Table (= civicrm_event)
So you want to show only 1 Views row, but list multiple fee options?
Couldn't you have a contextual filter of the event id, and limit it to show only price field values for that event .. so in your case two Views rows?
You could definitely theme/style this however you wanted using standard Drupal theme preprocess and templates for the View's format or rows.
Have you tried a format of "Unformatted List" playing with the html wrappers of the fields? You can set them to have no wrappers, or and you could probably get them to go inline.
Here's an example removing much of the
Try importing this example, it has a contextual filter too, the event id
If that doesn't get close to what you need...
The fee amounts are multiple rows in the database, using Views to fetch event price options, will return multiple rows
You could use a View within a View. Your one row in your main View would contain another View with 2 rows.
Comment #26
Katy Jockelson commentedThanks so much. I just finished editing my previous comment with an update on where I'd got to. So now our thread is a little confused!
I found a different filter that worked, and as you'll see - I ended up with my referenced view within a view.
Comment #27
Katy Jockelson commentedI'm coming back to this thread in the hope you can help.
I have a view, happily pulling through the event fees via another view. But it's not pulling through the early-bird fee. For an event where there is one regular fee and one early-bird, it's just printing the regular one twice. Any ideas? Thank you.