Adding Zendesk forum search to your external site

This is a example of adding Zendesk forum search functionality to a external website. You need to make sure to have jQuery libraries loaded. The script loads our default libraries which include jQuery but if you want a lighter page or already load them you can remove

src=”http://assets.zendesk.com/assets/bootstrap.js?1325706925″ type=”text/javascript”

Here is basic page code:

<html>
   <head>
 <script src="http://assets.zendesk.com/assets/bootstrap.js?1325706925" type="text/javascript"></script>
       <title>dropbox test page</title>
   </head>

   <body>
<div id="search">
<li>
          <label for="zenSearch">Subject</label>
           <span> (required) </span>
          <input class="required" type="text" name="zenSearch" id="zenSearch" style="width: 196px" value=""/>
       </li>
 <input type='button' value='Search' onclick='ZendeskSearch();'>
</div>
<script>
var ZENDESK_DOMAIN = 'https://support.zendesk.com';
ZendeskSearch = function() {
jQuery('#zendesk_search_results').html('');
jQuery.getJSON(ZENDESK_DOMAIN + '/api/v1/search?callback=?&query=' + jQuery('#zenSearch').val())
    .done(function(results) {
        var list = $j('#zendesk_search_results');
        jQuery(results).each(function(i, result) {
            list.append("<li>" +
                          "<a href='" + ZENDESK_DOMAIN +
                                    "/entries/" +
                                    result.id +
                                    "'>" +
                          result.title +
                          "</a></li");
        });
    });
}
</script>
#zendesk_search_results

<ul id="zendesk_search_results">
</ul>
   </body>
</html>

Slide Categories in Zendesk forums

This will create sliding Categories in Zendesk. The forum articles will be hidden until you click on the on the category header.

$j(document).ready(function()

{
  //hide the all of the element with class category
  $j(".category").hide();
  //toggle the componenet with class category
  $j(".category-header").click(function()
  {
    $j(this).next(".category").slideToggle(600);
  });
});

Adding to dates in Liquid Template

Adding to or Subtracting from dates using liquid template is a problem because the date you are trying to change is already rendered. So we go back to old fashion math, checking the month and the new date that you have separated out and done the subtracting or addition. Then you render the proper month and the new day.

The code will be on my gist here

In Flanders Fields

In Flanders Fields
By: Lieutenant Colonel John McCrae, MD (1872-1918)
Canadian Army
In Flanders Fields the poppies blow
Between the crosses row on row,
That mark our place; and in the sky
The larks, still bravely singing, fly
Scarce heard amid the guns below.

We are the Dead. Short days ago
We lived, felt dawn, saw sunset glow,
Loved and were loved, and now we lie
In Flanders fields.

Take up our quarrel with the foe:
To you from failing hands we throw
The torch; be yours to hold it high.
If ye break faith with us who die
We shall not sleep, though poppies grow
In Flanders fields.

It’s the 100th anniversary of the end of World War I

So here is Tommy

 

TOMMY

by Rudyard Kipling (1865-1936)

 

I went into a public-’ouse to get a pint o’ beer,
The publican ‘e up an’ sez, “We serve no red-coats here.”
The girls be’ind the bar they laughed an’ giggled fit to die,
I outs into the street again an’ to myself sez I:
O it’s Tommy this, an’ Tommy that, an’ “Tommy, go away”;
But it’s “Thank you, Mister Atkins”, when the band begins to play,
The band begins to play, my boys, the band begins to play,
O it’s “Thank you, Mister Atkins”, when the band begins to play.

I went into a theatre as sober as could be,
They gave a drunk civilian room, but ‘adn’t none for me;
They sent me to the gallery or round the music-’alls,
But when it comes to fightin’, Lord! they’ll shove me in the stalls!
For it’s Tommy this, an’ Tommy that, an’ “Tommy, wait outside”;
But it’s “Special train for Atkins” when the trooper’s on the tide,
The troopship’s on the tide, my boys, the troopship’s on the tide,
O it’s “Special train for Atkins” when the trooper’s on the tide.

Yes, makin’ mock o’ uniforms that guard you while you sleep
Is cheaper than them uniforms, an’ they’re starvation cheap;
An’ hustlin’ drunken soldiers when they’re goin’ large a bit
Is five times better business than paradin’ in full kit.
Then it’s Tommy this, an’ Tommy that, an’ “Tommy, ‘ow’s yer soul?”
But it’s “Thin red line of ‘eroes” when the drums begin to roll,
The drums begin to roll, my boys, the drums begin to roll,
O it’s “Thin red line of ‘eroes” when the drums begin to roll.

We aren’t no thin red ‘eroes, nor we aren’t no blackguards too,
But single men in barricks, most remarkable like you;
An’ if sometimes our conduck isn’t all your fancy paints,
Why, single men in barricks don’t grow into plaster saints;
While it’s Tommy this, an’ Tommy that, an’ “Tommy, fall be’ind”,
But it’s “Please to walk in front, sir”, when there’s trouble in the wind,
There’s trouble in the wind, my boys, there’s trouble in the wind,
O it’s “Please to walk in front, sir”, when there’s trouble in the wind.

You talk o’ better food for us, an’ schools, an’ fires, an’ all:
We’ll wait for extry rations if you treat us rational.
Don’t mess about the cook-room slops, but prove it to our face
The Widow’s Uniform is not the soldier-man’s disgrace.
For it’s Tommy this, an’ Tommy that, an’ “Chuck him out, the brute!”
But it’s “Saviour of ‘is country” when the guns begin to shoot;
An’ it’s Tommy this, an’ Tommy that, an’ anything you please;
An’ Tommy ain’t a bloomin’ fool — you bet that Tommy sees!