Closed (fixed)
Project:
Views Datasource
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
30 Apr 2009 at 18:36 UTC
Updated:
23 Jun 2010 at 21:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
mummybot commentedI spent ages banging my head against a wall, but figured it out in the end. Of course a node is not going to contain all of the information if it is linked across multiple tables through CCK, image attachment or by some other means. So if you are attaching images or relating them to other content types, you will need to define the relationship within your view.
My steps:
In the views UI control panel I defined a relationship, in my case it was to the new content type which I had created.
Then in fields there was another option of group of fields to choose from (in my case it was 'file'). I then specified the specific field I was after, File:Path.
Voila! I hope that helps.
Comment #2
erichomanchuk@fosterinteractive.com commentedTHATS IT!
Thanks a lot this was bugging me too. I thought It was some stupid issue with cck and views but it actually makes sense why you need to define the relationship. I was about to go crazy and start hacking the module, glad I don't have too.
Thanks again.
Comment #3
jcamfield commentedI think this is the same root problem I'm having at http://drupal.org/node/459628 ; but my relationship options are only taxonomy/parent term, node revision, and some comment ones; when I need content connections
Comment #4
allisterbeharry commentedCould you give some more details on your View - what fields do you want to pull in? I'll try to recreate it and see if I can help.
Comment #5
aaron commentedThe issue I see with #1 is that it doesn't work with imagecache. Additionally, it won't honor when you rewrite the path in the view field settings, nor if you use a 'global custom text' field.
Comment #6
aaron commentedseems it might be nice somehow to specify (per field, i suppose) whether to output a field's value or its output in the json.
Comment #7
allisterbeharry commentedComment #8
irishgringo commentedthis is exactly the issue I am having. I still have to figure out how the relationship part works. did you ever get this to work with ImageCache?
I think its strange that a normal view will display an ImageCache url... but not in JSON.
Comment #9
irishgringo commentedI was able to get the URL's to ImageCached images to work... but not completely.
I did this by creating a relationship. in VIEWS. I suppose it makes sense, but I still cant see why a PAGE view will display all of the image cache items, no problems. But no luck with the JSON views module.
this is what my JSON output looks like:
{
"nid" : "891",
"node_title" : "Aero Mexico",
"node_data_field_retailertype_field_retailertype" : "airline",
"node_type" : "merchant2",
"node_vid" : "891",
"node_data_field_logo_field_logo_fid" : "7",
"node_data_field_logo_field_logo_list" : "1",
"node_data_field_logo_field_logo_data" : "a:3:{s:11:\"description\";s:0:\"\";s:3:\"alt\";s:0:\"\";s:5:\"title\";s:0:\"\";}",
"files_node_data_field_logo_fid" : "7",
"files_node_data_field_logo_filepath" : "sites\/v01.myc.info\/files\/logos\/images.jpg",
},
But the problem I am having is the:
"files_node_data_field_logo_filepath" : "sites\/v01.myc.info\/files\/logos\/images.jpg",
it is the URL to the ImageCached version of the image... but all of those extra characters is a problem. I am pushing this out to an iPhone app, ( trying to anyway)... So I suppose I can substitute all of the \/ .. but why are they there anyway?
I am using the JSON DATA Document plugin in views to get this.
Comment #10
KerriO commentedI've been having the same issue as you, and I've gotten halfway there… Here's what I had to do:
1) First, I had to add the Content Field of the image to the Fields area (this was the only way I could get it listed in relationships).
2) Then I added Relationships for that image Content field and Upload:Attached Files
3) I added the File:Path. There will be a "Relationships" dropdown menu toward the top of this field's options where you can select your image field.
Now the only problem with this method, is so far, I can only figure out how to get it to display the path beginning from the root directory, rather than the entire url (which is what I actually need). Because unlike using the straight-forward way, it doesn't give you the choices of how the info is output. And using the "Rewrite the output of this field" option doesn't seem to make a different.
At least it's workable, though.
If you, or anyone else figures out how to get this to work as a full url, let me know!
Comment #11
irishgringo commentedActually, I did get this to work using pretty much your same solution. Its actually pretty simple when you get the hang of it. But I also have the same problem of getting the entire URL with file path.
Comment #12
mcfilms commented@Kerrio and @vinceyoumans in #10 and #11 above...
Are you both retrieving the IMAGECACHE url of the file? I can manage to get the URL of the original file upload. Something like: sites/default/files/image.jpg But I am trying to get Views to point to the ImageCache version, which would be more like: sites/default/files/imagecache/newsaward_left/image.jpg, Where newsaward_left is one of my imagecache presets.
Is this what you were both able to do? Or was it retrievng the path for the image upload?
Thanks!
Comment #13
irishgringo commentedcan you confirm that you are getting the path: sites/default/files/image.jpg
you said you are getting the URL of the image.
Comment #14
mcfilms commentedYup, I can confirm that is not working. Enclosed are screenshots of my set-up and my XML output. As you can see the output is to the image uploaded into sites/default/files/ NOT THE IMAGECACHE. So that is why I was asking if YOU were sure you were getting the imagecache version.
For now, my workaround is to get the image file name and map to the path inside of Flash when the XML is read in.
Another note to anyone passing this way -- you cannot have your image upload node allow more than one image to be attached. It will not pass to your XML. The solution is to provide additional separate image upload filefields for each image.
Comment #15
irishgringo commentedthis is becoming a real headach... displaying multiple images should be pretty doable. I am thinking that the services module does make more sense.
vince
Comment #16
mcfilms commentedGood Luck. I came here from the Services module. I think you will find the same problems there. (And some extra bonus ones.) At least you will if you are trying to use Views. I believe the problem is that no one has cracked to way to get the path to an imagecache version of an image out of Views.
Comment #17
allisterbeharry commentedHello, I'm really sorry it took me so long to get with this. The core issue here is really the limitation of the alpha modules to reading the Views fields as their raw results and field ids only. This is fixed for the next release. e.g: the attached screenshot views_fields shows a view with an imagefield called Picture. When you configure this and choose format -> scale50(the name of a preset) image, this is the XML generated:
by the views_xml plugin for node 4 which has a picture:
node>
]>
Note that because the field is rendered fully, your app have to extract the img src URL from the
tag using regexp or however you want
I'll have the new code committed today so you can try it out. The issue with multiple images per field is basically the need to correctly handle the case when a view field has an array of multiple values - this will also be fixed. Thanks for trying out the module and giving me feedback on what needs to be done - all these changes will be rolled into the beta1 release of the module.
Comment #18
allisterbeharry commentedHi see my reply to vinceyoumans - I'm going to commit the needed changes to the module today and have a reasonably usable module beta. The alpha releases had basically minimum features, so now that I have a better idea of how the module will be used in the real world I'm going to add the desired features and restructure it properly as a legit Drupal Views citizen. Thanks very much for your feedback.
Comment #19
mattkaneart commentedallisterbeharry, I'm so happy to see this is on it's way to being worked out. I have been using a static text field to relay the image URL in my XML feeds. Not so ideal, but manageable. Can you give any idea of when this beta release might be made available for download? I'm a bit green to Drupal's CVS, so I'm not very certain where exactly you're committing these changes.
Comment #20
allisterbeharry commentedThanks for waiting for this - I'm still banging this out - and the new release will be out today (26th). If you want in the meantime you could download the latest dev snapshot and try out the views_xml raw plugin which has the new options: http://ftp.drupal.org/files/projects/views_datasource-6.x-1.x-dev.tar.gz
You should clean you views_datasource folder before you put in the new version and right now only the raw format is enabled for views_xml
I'm gonna mark the new release as ALPHA3-R2 because only the JSON and XML plugins are rewritten. The XHTML and RDF are still using the rubbish raw fields for now until I fix them.
Comment #21
mcfilms commentedHi,
Did this fix make it into the 6.x-1.x-dev Download (30.34 KB) 2010-Feb-13 ?
Or does it still need to be downloaded from the link above?
Thank you for this module Allister. I used it to bring Drupal's CMS features to a Flash site I am developing. It is at:
http://folonisarchitects.com/folonis/demo42/
On that one I hard-coded the path and added the file names. But it would be nice next time to just use the real urls.
Comment #22
allisterbeharry commentedThe correct field output for a single valued field should be in the current dev release, but I haven't coded handling multiple field values. Correctly handling multiple values for a field is the current top priority for this module as there are many fields like taxonomy terms that have multiple values. I will commit this code as soon as I can.
Comment #23
KerriO commentedHi, just wanted to let you know that I just used the dev version on a new site, and it works just as I expected it would. Thanks for the updates!
Comment #24
allisterbeharry commentedissues with single or multiple-valued imagefields and imagecache should be resolved in 6.x-1.0-beta1