{"_id":"56850afe65976e0d00001c9b","__v":0,"category":{"_id":"543264d3f2f806080098ad40","project":"5431c59ea55723080068e155","version":"5431c59ea55723080068e158","pages":["543249453ee609080061800c","543f96e4051bdc0e00dfbf09","54324b909afb2a080013cce0","54359c9e5e1b202000438229","54483f7bcfb4580800d5e2a8","546e2dfe0f33a80800f58518","56850afe65976e0d00001c9b"],"__v":8,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-06T09:45:55.706Z","from_sync":false,"order":2,"slug":"how-to","title":"How-to"},"version":{"_id":"5431c59ea55723080068e158","project":"5431c59ea55723080068e155","__v":8,"createdAt":"2014-10-05T22:26:38.927Z","releaseDate":"2014-10-05T22:26:38.927Z","categories":["5431c59ea55723080068e159","54325f53f2f806080098ad37","543264b1f2f806080098ad3e","543264c8f2f806080098ad3f","543264d3f2f806080098ad40","543264f42aca39080046d81e","5435bbf15e1b20200043834d","54e9cfb4f152c50d009b49ed"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"project":"5431c59ea55723080068e155","parentDoc":null,"user":"542ea80e6b0eb6080066c9d5","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-31T11:01:18.139Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"The Tea Theme Options is provided with a list of plugins, such as a super powerfull Search Engine which uses ElasticSearch.\nHere is how to display results from the Search Engine.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n  //Get results from Tea_Theme_Options, instance of `$tea` variable.\\n  $results = $tea->search()->searchContents();\\n?>\\n<?php if ($results['total']): ?>\\n  <aside class=\\\"filter-search\\\">\\n    <ul>\\n      <?php foreach ($results['types'] as $typ): ?>\\n        <li><?php echo $typ ?> (<?php echo count($results['results'][$typ]) ?>)</li>\\n      <?php endforeach ?>\\n    </ul>\\n  </aside>\\n\\n  <section class=\\\"results\\\">\\n    <?php foreach ($results['results'] as $type => $type_res): ?>\\n      <h2><?php echo sprintf(__('%s (%d)'), $type, count($type_res)) ?></h2>\\n      <div class=\\\"row\\\">\\n        <?php foreach ($type_res as $res): ?>\\n          <?php\\n            //Get source and score.\\n            $score = $res['score'];\\n            $source = $res['source'];\\n            //Get datas.\\n            $id = $source['id'];\\n            $title = $source['title'];\\n            $content = $source['content'];\\n            //Include template.\\n            if ('category' == $type || 'post_tag' == $type) {\\n              $link = get_term_link(intval($id), $type);\\n          ?>\\n\\n<article class=\\\"article\\\" itemscope itemtype=\\\"http://schema.org/BlogPosting\\\">\\n  <h3 itemprop=\\\"name\\\"><?php echo $title ?> (<?php echo $score ?>)</h3>\\n  <?php if (!empty($content)): ?>\\n    <div class=\\\"media-content\\\" itemprop=\\\"headline\\\"><?php echo $content ?></div>\\n  <?php endif ?>\\n  <a href=\\\"<?php echo $link ?>\\\" title=\\\"<?php echo esc_html($title) ?>\\\" itemprop=\\\"url\\\"><?php _e('See all') ?></a>\\n</article>\\n\\n        <?php\\n            }\\n            else if ('post' == $type) {\\n              $date = isset($source['date']) ? date('j F Y à H:i', strtotime($source['date'])) : date('j F Y à H:i');\\n              $excerpt = isset($source['excerpt']) ? $source['excerpt'] : '';\\n              $link = get_permalink($id);\\n              //get author datas\\n              $author = array(\\n                'id' => $source['author'],\\n                'name' => get_the_author_meta('display_name', $source['author']),\\n                'link' => get_author_posts_url($source['author'])\\n              );\\n              //get date datas\\n              $date = array(\\n                'complete' => date('c', strtotime($source['date'])),\\n                'display' => date('j F Y à H:i', strtotime($source['date']))\\n              );\\n          ?>\\n\\n<article class=\\\"article\\\" itemscope itemtype=\\\"http://schema.org/BlogPosting\\\">\\n  <aside class=\\\"post-categories\\\" itemprop=\\\"keywords\\\">\\n    <ul>\\n      <?php get_the_term_list($id, 'category', '<li>', ',</li><li>', '</li>') ?>\\n    </ul>\\n  </aside>\\n\\n  <?php if (has_post_thumbnail($id)):\\n    $image = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'thumbnail');\\n  ?>\\n    <a href=\\\"<?php echo $link ?>\\\" title=\\\"<?php echo esc_html($title) ?>\\\" class=\\\"thumbnail\\\" itemprop=\\\"url\\\">\\n      <img src=\\\"<?php echo $image[0] ?>\\\" alt=\\\"\\\" width=\\\"<?php echo $image[1] ?>\\\" height=\\\"<?php echo $image[2] ?>\\\" />\\n    </a>\\n  <?php endif ?>\\n\\n  <h3 itemprop=\\\"name\\\"><?php echo $title ?> (<?php echo $score ?>)</h3>\\n  <span class=\\\"media-time\\\">\\n    <?php echo sprintf(\\n      __('By <a href=\\\"%s\\\" itemprop=\\\"author\\\">%s</a> on <time datetime=\\\"%s\\\" itemprop=\\\"datePublished\\\">%s</time>'),\\n      $author['link'],\\n      $author['name'],\\n      $date['complete'],\\n      $date['display']\\n    ); ?>\\n  </span>\\n\\n  <div class=\\\"media-content\\\" itemprop=\\\"headline\\\"><?php echo $excerpt ?></div>\\n  <a href=\\\"<?php echo $link ?>\\\" title=\\\"<?php echo esc_html($title) ?>\\\" itemprop=\\\"url\\\"><?php _e('Read more') ?></a>\\n</article>\\n\\n        <?php\\n            }\\n          ?>\\n        <?php endforeach ?>\\n      </div>\\n    <?php endforeach ?>\\n  </section>\\n<?php else: ?>\\n  <section class=\\\"results\\\">\\n    <div class=\\\"row\\\">\\n      <p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.') ?></p>\\n    </div>\\n  </section>\\n<?php endif ?>\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"use-search-engine","type":"basic","title":"Use Search Engine"}
The Tea Theme Options is provided with a list of plugins, such as a super powerfull Search Engine which uses ElasticSearch. Here is how to display results from the Search Engine. [block:code] { "codes": [ { "code": "<?php\n //Get results from Tea_Theme_Options, instance of `$tea` variable.\n $results = $tea->search()->searchContents();\n?>\n<?php if ($results['total']): ?>\n <aside class=\"filter-search\">\n <ul>\n <?php foreach ($results['types'] as $typ): ?>\n <li><?php echo $typ ?> (<?php echo count($results['results'][$typ]) ?>)</li>\n <?php endforeach ?>\n </ul>\n </aside>\n\n <section class=\"results\">\n <?php foreach ($results['results'] as $type => $type_res): ?>\n <h2><?php echo sprintf(__('%s (%d)'), $type, count($type_res)) ?></h2>\n <div class=\"row\">\n <?php foreach ($type_res as $res): ?>\n <?php\n //Get source and score.\n $score = $res['score'];\n $source = $res['source'];\n //Get datas.\n $id = $source['id'];\n $title = $source['title'];\n $content = $source['content'];\n //Include template.\n if ('category' == $type || 'post_tag' == $type) {\n $link = get_term_link(intval($id), $type);\n ?>\n\n<article class=\"article\" itemscope itemtype=\"http://schema.org/BlogPosting\">\n <h3 itemprop=\"name\"><?php echo $title ?> (<?php echo $score ?>)</h3>\n <?php if (!empty($content)): ?>\n <div class=\"media-content\" itemprop=\"headline\"><?php echo $content ?></div>\n <?php endif ?>\n <a href=\"<?php echo $link ?>\" title=\"<?php echo esc_html($title) ?>\" itemprop=\"url\"><?php _e('See all') ?></a>\n</article>\n\n <?php\n }\n else if ('post' == $type) {\n $date = isset($source['date']) ? date('j F Y à H:i', strtotime($source['date'])) : date('j F Y à H:i');\n $excerpt = isset($source['excerpt']) ? $source['excerpt'] : '';\n $link = get_permalink($id);\n //get author datas\n $author = array(\n 'id' => $source['author'],\n 'name' => get_the_author_meta('display_name', $source['author']),\n 'link' => get_author_posts_url($source['author'])\n );\n //get date datas\n $date = array(\n 'complete' => date('c', strtotime($source['date'])),\n 'display' => date('j F Y à H:i', strtotime($source['date']))\n );\n ?>\n\n<article class=\"article\" itemscope itemtype=\"http://schema.org/BlogPosting\">\n <aside class=\"post-categories\" itemprop=\"keywords\">\n <ul>\n <?php get_the_term_list($id, 'category', '<li>', ',</li><li>', '</li>') ?>\n </ul>\n </aside>\n\n <?php if (has_post_thumbnail($id)):\n $image = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'thumbnail');\n ?>\n <a href=\"<?php echo $link ?>\" title=\"<?php echo esc_html($title) ?>\" class=\"thumbnail\" itemprop=\"url\">\n <img src=\"<?php echo $image[0] ?>\" alt=\"\" width=\"<?php echo $image[1] ?>\" height=\"<?php echo $image[2] ?>\" />\n </a>\n <?php endif ?>\n\n <h3 itemprop=\"name\"><?php echo $title ?> (<?php echo $score ?>)</h3>\n <span class=\"media-time\">\n <?php echo sprintf(\n __('By <a href=\"%s\" itemprop=\"author\">%s</a> on <time datetime=\"%s\" itemprop=\"datePublished\">%s</time>'),\n $author['link'],\n $author['name'],\n $date['complete'],\n $date['display']\n ); ?>\n </span>\n\n <div class=\"media-content\" itemprop=\"headline\"><?php echo $excerpt ?></div>\n <a href=\"<?php echo $link ?>\" title=\"<?php echo esc_html($title) ?>\" itemprop=\"url\"><?php _e('Read more') ?></a>\n</article>\n\n <?php\n }\n ?>\n <?php endforeach ?>\n </div>\n <?php endforeach ?>\n </section>\n<?php else: ?>\n <section class=\"results\">\n <div class=\"row\">\n <p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.') ?></p>\n </div>\n </section>\n<?php endif ?>\n", "language": "php" } ] } [/block]