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) »
  • Custom Data in Drupal Views
Pages: [1]

Author Topic: Custom Data in Drupal Views  (Read 4900 times)

nmudgal

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
    • It's Really Me
  • CiviCRM version: civicrm 3.3
  • CMS version: Drupal 6.20
  • MySQL version: mysql 5
  • PHP version: php 5
Custom Data in Drupal Views
April 07, 2011, 09:22:33 am
I made a custom data as a file type & uploaded images in it only.
Then I was trying to make a view from view type "Civicrm_event" in which after selecting fields as "civicrm_custom_upload" [or custom data field name] I was able to fetch only the uploaded file id not the file itself.
Like how can I access that "uri" field from civicrm_file table into that view?
Quote
SELECT civicrm_event.id AS id, civicrm_event.title AS civicrm_event_title, civicrm_value_image_upload_4.image_7 AS civicrm_value_image_upload_4_image_7 FROM civicrm_event civicrm_event  LEFT JOIN civicrm_value_image_upload_4 civicrm_value_image_upload_4 ON civicrm_event.id = civicrm_value_image_upload_4.entity_id

Currently this query is being run which fetch uploaded file id mapped with drupal event id . I like to show file in place of that file id then I have to fetch "uri" field from civicrm_file according to particular "event_id", then how can I do this ?
Hope I am clear enough!
Thanks!
GPG Key Fingerprint: 8B97 082A D923 2860 E0BE 3ED3 8F81 0702 6AE9 2A57

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: Custom Data in Drupal Views
April 07, 2011, 09:49:30 am

I suspect u'll need to improve the handlers for the file field in the views integration code to do what u need

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

nmudgal

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
    • It's Really Me
  • CiviCRM version: civicrm 3.3
  • CMS version: Drupal 6.20
  • MySQL version: mysql 5
  • PHP version: php 5
Re: Custom Data in Drupal Views
April 07, 2011, 10:03:33 am
But handler must have some query to achieve the existing thing & I am little confused about the relation between uri & the event id as what will be the sql query if you can help  or something?
GPG Key Fingerprint: 8B97 082A D923 2860 E0BE 3ED3 8F81 0702 6AE9 2A57

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: Custom Data in Drupal Views
April 07, 2011, 10:13:10 am

the custom data table is linked to the event table via entity_id

the file information and details are in civicrm_entity_file and civicrm_file

might want to peruse those tables and see how they are connected in the DB

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Custom Data in Drupal Views
April 07, 2011, 12:06:26 pm
You can customize your View templates and run your SQL that way. This tool also http://drupal.org/project/views_modify_query might help but it's not yet stable.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Custom Data in Drupal Views
April 09, 2011, 09:41:36 am
Quick solution to display the images uploaded by CiviCRM custom data in views, is to rewrite the output of the field with
Code: [Select]
<img src="<drupalpath>/civicrm/file?reset=1&id=[Field ID]&eid=[Entity ID]" />
Please see the attachment.

But definitely we need to modify the file field hander for views to display uploaded file.

Rajan

nmudgal

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
    • It's Really Me
  • CiviCRM version: civicrm 3.3
  • CMS version: Drupal 6.20
  • MySQL version: mysql 5
  • PHP version: php 5
Re: Custom Data in Drupal Views
April 09, 2011, 10:36:09 am
Quote from: Rajan Mayekar on April 09, 2011, 09:41:36 am
Quick solution to display the images uploaded by CiviCRM custom data in views, is to rewrite the output of the field with
Code: [Select]
<img src="<drupalpath>/civicrm/file?reset=1&id=[Field ID]&eid=[Entity ID]" />
Please see the attachment.

But definitely we need to modify the file field hander for views to display uploaded file.

Rajan

You must have modified too that handler on your installation to show images, id filed & respective uploaded data, if you can tell the code of that, then it would ease the work :-) [As I was not able to modify it properly.]
Thanks
GPG Key Fingerprint: 8B97 082A D923 2860 E0BE 3ED3 8F81 0702 6AE9 2A57

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: Custom Data in Drupal Views
April 09, 2011, 11:26:09 am

note that this also depends on the permissions. So might want to first check and get this working as uid=1 and then see the permissions you need to enabled (access uploaded files?)

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

nmudgal

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
    • It's Really Me
  • CiviCRM version: civicrm 3.3
  • CMS version: Drupal 6.20
  • MySQL version: mysql 5
  • PHP version: php 5
Re: Custom Data in Drupal Views
April 12, 2011, 07:50:48 am
yeah I got image working but a questions arises, how am I gonna give some default image. e.g . If some user didn't upload any image in the field then there should come some default image in place of image that is being fetched & wasn't found because user didn't upload it, then how can I do that? Using Drupal views arguments ? I tried a bit but wasn't successful .
If anyone can help regarding this too?
GPG Key Fingerprint: 8B97 082A D923 2860 E0BE 3ED3 8F81 0702 6AE9 2A57

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Custom Data in Drupal Views
April 12, 2011, 08:37:05 am
If you customize your view template, you can do it there.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom Data in Drupal Views

This forum was archived on 2017-11-26.