Hi,
I need to use json for one of the JavaScript applications. I found "views node feed" as the perfect module to get my views output as json.
The thing is I don't know how to format in the interface the module provides. I am new to this stuff but I am sure I can get hang of it easily.
Please see the user interface which the module provides but I can't understand how to use it and searched but could not find any help on the documentation.
Please see the attached image as to where I am stuck http://imagebin.ca/view/y9wEL5.html
I need the data to be in the below format for my javascript to work.
[
{'title':'Heavy Metal', 'results': [
['/metal/1', 'Disturbed - The Game', 'icons/metal.png'],
['/metal/2', 'Marilyn Manson - The Beautiful People', 'icons/metal.png'],
['/metal/3', 'Soil - 2 Skins', 'icons/metal.png'],
['/metal/4', 'Alestorm - Wenches & Mead', 'icons/metal.png']
]},
{'title':'Pop', 'results':[
['/pop/1', 'Michael Jackson - Bad', 'icons/pop.png'],
['/pop/2', 'Britney Spears - If U Seek Amy', 'icons/pop.png'],
['/pop/3', 'Take That - Relight My Fire', 'icons/pop.png'],
['/pop/4', 'Rick Astley - Never Gonna Give You Up', 'icons/pop.png']
]},
{'title':'Folk', 'results':[
['/folk/1', 'The Proclaimers - I\'m Gonna Be', 'icons/folk.png'],
['/folk/2', 'Bob Dylan - Hurricane', 'icons/folk.png'],
['/folk/3', 'Jason Mraz - Geek In The Pink', 'icons/folk.png'],
['/folk/4', 'Beirut - Nantes', 'icons/folk.png']
]}
]
I think I need to use the variables there I got an update from http://ivansotof.com/2009/10/drupal-modules-list
but I still can't get the data on my json file it turn out empty. I used something like. I am not sure where I am going wrong.
{
"nodes":
[
{
"uid" : "
echo $nodes->uid
",
"users_name" : "
print $nodes->users_name
"
},
]
}
Hope someone can help me out here its been two days I have been working on this.
Cheers,
Vishal
Comments
Comment #1
vishalkhialani commentedHI,
What ever php variable I type in the nodes template area does not work. Below is an example.
Cheers,
Vishal
Comment #2
andrewlevine commentedVishal, the only variable that views_node_feed provides is the $node object (so $nodes and $uid won't work). To see all the properties of the $node object you can use the devel module or simply var_dump() the $node variable. See this issue for reference.
Comment #3
vishalkhialani commentedHi,
I am new to php and drupal.
I got the devel module but I don't know how to use it to see all the properties of the $node object. Please advice where should I look ?
I managed to get the some of the data as an output after reading the other post. I used $node->name but when I want to use with the profiles I don't know how to do it as I can't find the variable to access.
Even var_dump() where do I use it and how ?
Thanks,
Cheers,
Vishal
Comment #4
andrewlevine commentedIf you go to the URL of the node (eg node/52) you will see a 'devel load' tab.
For var_dump see http://us3.php.net/var_dump. Use php.net to learn about php functions and api.drupal.org for Drupal core functions