Custom output for Json
| Project: | Views Datasource |
| Version: | 6.x-1.0-alpha3 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | allisterbeharry |
| Status: | active |
| Issue tags: | json custom output |
Jump to:
Hi,
I need a custom output format for Json as my 3rd party javascript application requires that. Is there a way to get that done ?
Below is a sample format which I need it in.
[
{'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']
]}
]
Cheers,
Vishal

#1
Well the first thing would be to define your view to have the data you want. Could you give me an idea of what schema your data has (what are title, results, etc.) and like what data types are you using - CCK ?
#2
Hi,
I need only the below data output its rather simple.
user name - which I am successful in getting the json with by typing
<?phpprint $node->name
?>
In the profile section I have created a text field named profile_industry1 but I don't know the variable name to use to put in the veiws node tempalte I tried $node->profile_industry1 but there is no output.
I am pretty new to drupal development so I don't know how to find the variable I need to use for this field.
Cheers,
Vishal
#3
any tricks on including the URL of an ImageCache Image in an XML file of some type?