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) »
  • retrieving multiple file names for profile
Pages: [1]

Author Topic: retrieving multiple file names for profile  (Read 572 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
retrieving multiple file names for profile
November 16, 2012, 09:10:16 am
I have a profile that is for assigned participants to upload images of pictures taken at an event and of images of receipts. There are multiple images so I am using a custom data that has multiple rows per entity_id. The profile allows for uploading the images and providing information about the images.

At the top of the profile I would like to display a list of images already uploaded with a thumbnail for each and links to edit or delete.

I do not know how to use the api to retrieve the image names.

It appears I can use something like this to get a single image name:
Code: [Select]

  $params = array(
      'version' => 3,
      'id' => $file_id,
      'debug' => 1,
  );
  $file = civicrm_api('file', 'get', $params);


Is there a way to retrieve an array of file names instead of one at a time retrieval?

Thanks
« Last Edit: November 16, 2012, 09:12:41 am by jere »

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: retrieving multiple file names for profile
November 19, 2012, 07:49:37 am
I am using executeQuery for now. I would still like to know if there is a way. It looks like if I pass an array of id's into the api as the id, it tries to interpret it as an integer. Perhaps if the api recognized the id as an array it could change the where clause to something like " x in (a, b, c)' and the change might work without affecting calls that use an integer. It could be a place to start, but this project is taking too long to dive into more new things now.

I am trying to use the api's in anticipation of the future, but it is not always working well when using multiple row custom data,  so I am still stuck with the executeQuery calls here and there.

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: retrieving multiple file names for profile
November 23, 2012, 10:03:30 pm
Hi,

I think being able to fetch several entities by id is useful indeed, and I like your 'id as array of id' param.

Could you try implementing it on file? haven't looked at the underlying bao/dao but I'm pretty sure there is a way of using an array of id already.

api/v3/File.php and the get function inside would be the starting point

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • retrieving multiple file names for profile

This forum was archived on 2017-11-26.