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) »
  • How to include a *single* image with an Event and create drupal view ...
Pages: [1]

Author Topic: How to include a *single* image with an Event and create drupal view ...  (Read 1654 times)

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
How to include a *single* image with an Event and create drupal view ...
October 31, 2014, 10:31:32 am
I need to create a drupal view, i.e. a listing of CiviEvents that includes an image for each event (see the attached design requirement). I can deal with all of the default event data, but not clear on how to get a image into the view that can also utilize drupals image styles.

 (btw: the forum topic 34532 (http://forum.civicrm.org/index.php/topic,34532.0.html) comes close, but no cigar.)

Suggestions??

Carl

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
October 31, 2014, 03:29:25 pm
doh - but i like cigars

so what is it that my explanation at http://forum.civicrm.org/index.php/topic,34532.msg146727.html#msg146727 fails for your use case? Just the image size? Is that something you can just control by uploading images of the right size? Guessing not so must be missing something about your use case.

Code: [Select]
Add a custom field for the file, and another custom field to then put the path of the file (Why? Because Views doesn't currently play nicely with the file in my experiments)

Then in a View pull in the 'event image path' and 'exclude from display' - then add a Custom text field with something like <img src="[event_image_path_8]"> (which is name of the custom field as Views sees it)

then display the View Block on the Event page(s)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
October 31, 2014, 07:27:12 pm
Hi, Pete! And thanks ...

First, I don't need to add multiple images, so that does simplify things.   Maybe I just misinterpreted your your instructions

ASIDE: [and I *did* get an error along the way, but I think that's another story: "Notice: Array to string conversion in HTML_QuickForm_Rule_Required->validate() (line 63 of /var/www/mysite.com/sites/all/modules/civicrm/packages/HTML/QuickForm/Rule/Required.php)" } - seems this is a known problem when creating a custom field, e.g. events and using "Any" as the event type. and has something to do with having using multiple, "any" for the events and/or a PHP version problem.

Onward.  This is what I did:
* went to admin to create a set of custom fields called ~Test~ and 'used for' Events of "any" kind, i.e. workshop, exhibition, etc.
* created a custom field called "Picture" with a type of 'file'
* and a second field called "Path", type alphanumeric.  (this is where it got confusing).

* after having some event data I went to create a drupal view using 'civicrm_entity' to create view fields for the picture and the path.
* this is where I had trouble.  ... "path", i.e. [path] is usually associated with "file", but in this case it would require an explicit entry of a path on the admin interface, which may not work well. So I just never could figure out what to do from that point.  And I couldn't find a token replacement for [path] on the file.

So was it necessary at all to create the path field in the custom field set, and create only the Picture file type? If so, how can I get the path for the picture and/or just get it to display??

Sorry, but I really missed the mark on this one. 

Carl

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 02:09:42 pm
You would need to make a View based on CiviEvents not CiviEntities - or at least that is what i have done for this to work
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 06:05:18 pm
Pete,

Yes, that's right! I want to use CiviEvent's default fields, and one custom field (image) for the view.

If you refer back to the screenshot of the client's design, you'll see that CiviEvent has all the data I need, except for the image.  And that's what I'm having trouble with.

Carl




petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 06:11:05 pm
you said

"after having some event data I went to create a drupal view using 'civicrm_entity' to create view fields for the picture and the path"

i am saying that is wrong - the View should be using civicrm_events as the entity type you choose when you create the View

or are we on different discussions?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 06:49:22 pm
Sorry, Pete! 

I'm using CiviEvents for the view.

The custom field for the image was, of 'file' type, and when I got to views, I could find all of the CiviEvent fields available, including the file, but was having trouble getting the path from the file, i.e. there was not a drupal token for path, i.e. [path]  to do a rewrite of the field.  Hence I could not display the image.

Carl

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 06:54:06 pm
then unsure.

you have done as explained above namely

Quote
Then in a View pull in the 'event image path' and 'exclude from display' - then add a Custom text field with something like <img src="[event_image_path_8]"> (which is name of the custom field as Views sees it)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
November 03, 2014, 09:54:39 pm
I think I'm getting closer ... but views is delivering a broken image link.

Q: When I define the image path field in the custom CiviEvent field, should it be of Type alphanumeric, file, or link??

FYI:
When the Image file uploaded from CiviEvent arrives in the Drupal View as the original file field (not the path field) the link exists and is found at http://mysite.com/sites/default/files/civicrm/custom/ThePicture.jpg and is represented by the token [event_image_one] , However it displays as broken. 

If I look at the file with a different image tool, it appears okay. 

If I replace the token path in the Rewrite output area to a different image with a literal address like MyThemeName/images/picture.jpg, its okay.

Carl




petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
November 04, 2014, 11:23:44 am
Good question. I used alphanumeric - didn't think about using Link - try both?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
November 04, 2014, 01:02:29 pm
Pete,

Hopefully this helps someone, but I just learned something that might be worth sharing.

When an image is uploaded to the website via an Event Custom Field type of 'file', the image lands in 'sites/default/files/civicrm/custom' . Any image that is placed in that directory can not be displayed.  I tested this my using rewrite in a drupal view and entered the location explicitly via an
Code: [Select]
<img src="the location"/>.  And the image is not shown ... none of the images will appear.  However, if I put one of those images into the theme/images directory, they work perfectly.  All of these experiments were conducted from Drupal views.

FYI: I did not need to create a path field and exclude display of the 'file' field to do this. In fact I never could get it to work that way ... it definitely had something to do with the location.

The kicker: So how dangerous is it, to remove .htaccess from that civicrm custom folder????  Scary, huh?  Well, as it turns out, removing the .htaccess from the civicrm/custom folder allows the images to be displayed!

I know, its a Cardinal Sin to do that, but the only way to workaround it is to manually place the images desired into a different folder, e.g. the theme/images folder, and rewrite the custom 'file'field with the literal location of the new directory, i.e. don't use a token.

OR

Find out some other way to get Event Management to upload a file to some other area.  Is there way to do this?

I don't mind manually moving the uploaded images as long as I don't have too many (and that could happen), but I don't like fooling with mother nature either, i.e. deleting the htaccess.

Got any suggestions???  Like is there someway to exercise the Resource Directory Extension for the images and and redirect files to that location via the civicrm.settings.php file??

Carl

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to include a *single* image with an Event and create drupal view ...
November 04, 2014, 01:37:41 pm
dang - i hadnt' spotted the image was failing for logged out users before

so my switch would be eg upload via imce (ie on Drupal side) - then just grab the path and paste in to a text field on the event - ie scrap the 'file' field on the event
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to include a *single* image with an Event and create drupal view ...
November 04, 2014, 01:47:00 pm
Actually, I *was* logged-in as admin while doing this, but could well be that wouldn't work if not logged in.

You know, I do like your suggestion of getting rid of the custom 'file' type field and just use an alphanumeric, or at least for the time being.

It *would* be nice if there were an image type field to chose from in the Custom event fields, huh?  I'll submit a request for a enhancement.  ;D

Thanks, Pete ... here come the Kudos!

Carl

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • How to include a *single* image with an Event and create drupal view ...

This forum was archived on 2017-11-26.