What are the available Vars when rendering Google Custom Search Engine?

29 views
Skip to first unread message

Fede CHL

unread,
Aug 12, 2013, 2:46:57 AM8/12/13
to google-ajax...@googlegroups.com
Hi, 

I'm customizing the snippets of a Google Custom Search Engine, but I'm having a hard time wondering about the available vars returned by the search. I can't properly render the snippets because I don't know what are the vars. I mean, from google blog, you have this "Vars", which is holding some data, but I don't know what this "Vars" is holding, neither how to print its attributes: 


<div id="mysite_webResult">
<div class="gs-webResult gs-result"
data-vars="{longUrl:function() {
var i = unescapedUrl.indexOf(visibleUrl);
return i < 1 ? visibleUrl : unescapedUrl.substring(i);}}">

<table>
<tr>
<td valign="top">
<div data-if="Vars.richSnippet" data-attr="0"
data-body="render('thumbnail',richSnippet,{url:unescapedUrl,target:target})"></div>
</td>

<td valign="top">
<div class="gs-title">
<a class="gs-title" data-attr="{href:unescapedUrl,target:target}"
data-body="html(title)"></a>
</div>
<div class="gs-snippet" data-body="html(content)"></div>
<div class="gs-visibleUrl gs-visibleUrl-short" data-body="longUrl()"></div>
<div style="& Vars.richSnippet.document">
<img data-attr="{src:Vars.richSnippet.document.filetypeImage}">
By <span data-body="Vars.richSnippet.document.author"></span> -
<span data-body="Vars.richSnippet.document.pageCount"></span> pages -
<span data-body="Vars.richSnippet.document.viewCount"></span> views
- last modified <span data-body="Vars.richSnippet.document.timeAgo"></span>
</div>

<div data-if="Vars.richSnippet && Vars.richSnippet.action" class="gs-actions"
data-body="render('action',richSnippet,{url:unescapedUrl,target:target})"></div>
</td>
</tr>
</table>
</div>

The above is the code suggested in the blog. As you'll see, there are some "Vars" variables which will show the data. I want to know what this Vars is holding, because I want to show different vCard from the metadata of the pages my project is holding. Can anyone point me out how to do it?

Thanks in advance, 

Fede

Fede CHL

unread,
Aug 13, 2013, 2:27:03 AM8/13/13
to google-ajax...@googlegroups.com
Well, I only had to RTFM: 


There, you can see that if you want to print your Vars, you may do:
<span data-body="JSON.stringify(richSnippet)"></span>
Inside of your snippets, and you'll see richSnippets. If instead of richSnippet you print Vars, you'll see all data sent by Google Custom Engine to your snippets.

Cheers, 

Fede

Reply all
Reply to author
Forward
0 new messages