Is it possible to create an asset that reads the query string and returns a different type of content depending on the query?
e.g.
site/page (default behaviour)
site/page?fmt=json
site/page?fmt=xml
Return different types of content
You can use the DB Datasource asset to do this.
For a one or the other case:
Set up a DB Datasource asset connected to ANY database, (it won't matter which).
Setup the dynamic variables on the DB Datasource asset with a get variable of what u need (i.e. type)
Setup the query of the DB Datasource to:
SELECT true WHERE %%DYNAMIC_VARIABLE%% = 'XML'
Setup an assetlisting to point to the db datasource listing datasource record sets
On the results page put the XML
On the no results page, put the other type OR nest another asset listing doing a check for another type like TEXT
Get it?
[quote]You can use the DB Datasource asset to do this.
For a one or the other case:
Set up a DB Datasource asset connected to ANY database, (it won't matter which).
Setup the dynamic variables on the DB Datasource asset with a get variable of what u need (i.e. type)
Setup the query of the DB Datasource to:
SELECT true WHERE %%DYNAMIC_VARIABLE%% = 'XML'
Setup an assetlisting to point to the db datasource listing datasource record sets
On the results page put the XML
On the no results page, put the other type OR nest another asset listing doing a check for another type like TEXT
Get it?[/quote]
Yep, thanks. I have not used the datasource asset for anything yet.
Presumably I could use a single datasource asset to get data for any asset I want?
(and do i have to use an asset list? Can i hit the datasource asset directly
cheers,
Richard
As far as I understand you can only use an asset listing. But you can run any query with them even if you don't return a result. (update, insert, delete, select)
Yes you can access the DB for anything, but if you are a Squiz SLA client, you will need to talk to Squiz about how this might affect your SLA.
Remember that the DB Datasource asset can not be used if you want to index the content for searches.
[quote]Is it possible to create an asset that reads the query string and returns a different type of content depending on the query?
e.g.
site/page (default behaviour)
site/page?fmt=json
site/page?fmt=xml[/quote]
You can use SQ_PAINT_LAYOUT=xxx&SQ_DESIGN=yyy - its a bit wordy but ok if you are just using it in scripts.
The easiest solution is to use a different URL so you have json.site/page and xml.site/page and apply the designs and paint layouts you need to these.
Otherwise you will have to do some custom development.