Project:Views Datasource
Version:6.x-1.0-alpha3
Component:Code
Category:support request
Priority:normal
Assigned:allisterbeharry
Status:closed (fixed)
Issue tags:json custom output

Issue Summary

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

Comments

#1

Component:User interface» Code
Category:feature request» support request
Assigned to:Anonymous» allisterbeharry

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

<?php
print $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?

#4

The next release of the JSON plugin will allow tweaking the JSON output using a template file. As long as the data you want to include exists as view fields, you'll be able to customize the JSON output using views-view-json-style.tpl.php and views-view-json-row.tpl.php in the theme subdirectory.

#5

Status:active» fixed

In 6.x-1.0-beta1 you can override the default templates for JSON and customize the output however you'd like.

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here