Getting a public event by id (Upcoming) - yql

I know the id of a public yql event. Why can't I get it by simply mentioning the id in WHERE clause like this:
Click here to see my yql console

You were very close - instead of id you'll want to use the parameter event_id. Here's a modified version of your search which works:
SELECT * FROM upcoming.events WHERE event_id = "9236524" | sort(field='start_date')
For Community YQL tables like upcoming.events, you can see the allowed parameters by clicking on the "desc" link on the far right. In this case it shows that searching by event_id is one of the options:
<select>
<key name="event_id" required="true" type="xs:string"/>
</select>

Related

Get internal tags in Ghost

Is there any way to get all internal tags in Ghost using the api and the get helper?
In my post.hbs template I can do this and it works:
{{#post}}
{{#foreach tags visibility="internal"}}
{{name}}
{{/foreach}}
{{/post}}
But in my page.hbs I tried this and it only shows tags with public visibility.
{{#get "tags" limit="all"}}
{{#foreach tags}}
{{name}}
{{/foreach}}
{{/get}}
I also tried
{{#get "tags" filter="visibility:internal"}}
and
{{#get "tags" visibility="internal"}}
but it does not return any tags.
Is this not implemented and if so why not? This would be super useful for my use case.
I did read the docs and https://themes.ghost.org/docs/get#section--fields- says that valid fields for tags are id, uuid, name, slug, description, image, created_at, created_by, updated_at, updated_by. Visibility is notably missing, does anyone know why?
You have to specify the visibility attribute when you access the tags, not when you retrieve them, in this case, it's in the foreach:
{{#get "tags" limit="all"}}
{{#foreach tags visibility="internal"}}
{{name}}
{{/foreach}}
{{/get}}
This will loop over the internal tags only. Apparently you have to get all the tags and then filter this way, I didn't find a way to get only the internal tags from the begining.

g:select tag in grails does not store key of list element in target field

I have the following codeline in my grails view
<g:select id="partner" name="partner.id" from="${org.strotmann.partner.Partner.partners}" optionKey="id" value="${auftragInstance?.kundenNr}" class="many-to-one" noSelection="['null': '']"/>
I expect it to show me the list specified in the from clause as a select box (that works fine)
After selecting an Item from the box I expect that it stores the id of that Item in the field specified in the value clause ( that does not work, always null)
I'm somewhat confused, because the followin codeLine does exactly what I expect:
<g:select id="partner" name="partner.id" from="${org.strotmann.partner.Partner.partners}" optionKey="id" value="${arbeitsgangInstance?.kundenNr}" class="many-to-one" noSelection="['null': '']"/>
Can anybody tell me where I can find a difference or how to recode my ?
peter
let me reformulate my question:
I have a list
org.strotmann.partner.Partner.partners
It contains partners with just the attribute name and of course the id.
I want the names in a selectList and want the id of a partner stored in
auftragInstance.kundenNr
feel free to code a working g:select
peter
The value attribute is used to provide the initial selection. The name attribute will contain the selected value when the form is submitted. In a controller you can get it like this:
def partner = params.partner
See:
select tag in grails documentation
thanks to comment from masc I found that there was just missing the following code snippet in save and update method of AuftragController:
if (params.partner.id == 'null')
salesOrderInstance.kundenNr = 0
else
salesOrderInstance.kundenNr = params.partner.id.toLong()
That code block was allready contained in ArbeitsgangController, and therefore the second html-line in my question was working fine.
the following select (with id and value clauses omitted) will also do:
<g:select name="partner.id" from="${org.strotmann.partner.Partner.partners}" optionKey="id" class="many-to-one" noSelection="['null': '']"/>
sorry the value entry
value="${auftragInstance?.kundenNr}"
must not be removed, it is important for update.

Add an option to a g:select after it loaded elements dynamically?

I have a select like this:
<g:select style="width: 500px;;" name="ftp" value="${ftpResource.host[0]}"
from="${ftpResource.host}"
optionKey="${ftpResource.id}"
keys="${ftpResource.id}" />
but I want to add a message in the drop down list and then more information, like:
ftp1
ftp2
ftp3
this message
ftp kind 1
ftp kind 2
ftp kind 3
I tried this:
from="${[ftpResource.host, 'Message', ftpkindResource.host]}"
but it displays it inline, How can I do that?
(and taking a chance of this post, with property 'keys' can I set the Ids live values to send them in params for each option?)

How to get a list of response fields in YQL

Given the table answers.getquestion; I was under the impression that "desc answers.getquestion" would provide a list of all the possible response fields for querying answers.getquestion. Instead it mentions question_id as a required field.
Where/How do I get a list like the one mentioned in http://developer.yahoo.com/answers/V1/getQuestion.html under response fields? Also, where can I see the mapping identifying question_id in the request to be id in the response?
In YQL, the "desc" command gives a brief summary of the table (ref: YQL docs). In your example, requesting desc answers.getquestion shows some simple info about this table:
<table hash="2143dbc888c9ccf3daac6778d0f57a32"
name="answers.getquestion" security="ANY">
<meta>
<author>James Broad</author>
<documentationURL>http://developer.yahoo.com/answers/V1/getQuestion.html</documentationURL>
<sampleQuery>select * from answers.getquestion where question_id="20090526102023AAkRbch"</sampleQuery>
</meta>
<request>
<select>
<key name="appid" private="true" type="xs:string"/>
<key name="question_id" required="true" type="xs:string"/>
</select>
</request>
</table>
To your question about the response fields, they will come directly through from the Yahoo! Answers Get Question API call. The YQL table is simply a wrapper for the underlying API, and so the results will simply flow back through YQL.
For example, you can see the results from select * from answers.getquestion where question_id="1005120800412" in the YQL console:
<Question xmlns="urn:yahoo:answers" id="1005120800412" type="Answered">
<Subject>Why is there no TITLE tag in the header of answers.yahoo.com?</Subject>
<Content>Come on, you guys. It's not valid HTML if there's no title. :) Correction: there's no TITLE tag in any of the edit screens, including the one I'm using to add these details. Sorry, my bad.</Content>
<Date>2005-12-08 08:22:33</Date>
<Timestamp>1134058953</Timestamp>
etc.
</Question>

handling multi-select with no selection

I used grails generate-all on my application. The Author view has a multi-select which allows for a number of Book instances:
<g:select multiple="true" ... />
However, if I edit an existing Author who owns 5 out of total 15 books (the multi-select shows 15 books, 5 selected), unselect all books and click save, the Author still keeps their 5 books. From what I can tell, no book input from the form - books property of Author don't get changed.
Now, I can test for this in my controller (something like this):
if (params?.books.size() < 1) {
authorInstance.books = []
}
Is this the way to do it, or is there a better way?
Most examples I've seen use:
authorInstance.books.clear()
I had the same problem, that a multi select list can not be emptied by default data binding, as the params map does not contain fields with a value of NULL.
To circumvent this, you can do this in your .gsp:
<g:hiddenField name="books" value="" />
<g:select multiple="true" name="books" />
When you post this form elements, the multi select will override the hidden field. If the multi select is empty, you will fallback to the empty string.
Not pretty, but get the job done, when you can not alter the controller action.

Resources