Salut,

Je ne connais pas ce thème mais ça ressemble à la recherche live de Noviny
(les résultats qui s'affiche au fur et à mesure de la frappe).

2015-02-01 19:48 GMT+01:00 brol <[email protected]>:

> Bonjour,
>
> dans boston, j'ai tout un tas de code mais je ne vois pas ce que c'est
> censé faire, quelqu'un peut me renseigner ?
>
> merci
>
> $core->tpl->addValue('MyEntriesCount',array('myTpl','MyEntriesCount'));
> $core->tpl->addValue('MyCommentsCount',array('myTpl','MyCommentsCount'));
>
> # Ajax search URL
>
> $core->url->register('ajaxsearch','ajaxsearch','^ajaxsearch(?:(?:/)(.*))?$',array('urlsBokeh','ajaxsearch'));
>
> class myTpl
> {
>         /*
>         Cette fonction affiche le nombre de billets
>         */
>         public static function MyEntriesCount($attr)
>         {
>                 $tbl_billets = $GLOBALS['core']->blog->prefix."post";
>         $billets = $GLOBALS['core']->con->select("
>             SELECT count(post_id) as somme
>             FROM ".$tbl_billets." billets
>             WHERE post_status=1 AND
>                   blog_id='lab'")->field("somme");
>             return '<?php echo '.$billets.'; ?>';
>         }
>
>
>      /*
>         Cette fonction affiche le nombre de commentaires
>         */
>         public static function MyCommentsCount($attr)
>         {
>             global $core;
>         $tbl_billets = $GLOBALS['core']->blog->prefix."post";
>                 $tbl_comments = $core->blog->prefix."comment";
>         $comments = $core->con->select("
>             SELECT count(comment_id) as somme
>             FROM ".$tbl_billets." billets, ".$tbl_comments." comments
>             WHERE comments.post_id = billets.post_id AND
>                   billets.post_status=1 AND
>                   comment_status=1 AND
>                   comment_trackback=0 AND
>                   blog_id='asiam'")->field("somme");
>
>             return '<?php echo '.$comments.'; ?>';
>         }
>
> }
>
> class urlsBokeh
> {
>         public static function ajaxsearch($args)
>         {
>                 global $core;
>                 $res = '';
>
>                 try
>                 {
>                         if (!$args) {
>                                 throw new Exception;
>                         }
>
>                         $q = rawurldecode($args);
>                         $rs = $core->blog->getPosts(array(
>                                 'search' => $q,
>                                 'limit' => 5
>                         ));
>
>                         if ($rs->isEmpty()) {
>                                 throw new Exception;
>                         }
>
>                         $res = '<ul>';
>                         while ($rs->fetch())
>                         {
>                                 $res .= '<li><a
> href="'.$rs->getURL().'">'.html::escapeHTML($rs->post_title).'</a></li>';
>                         }
>                         $res .= '</ul>';
>                 }
>                 catch (Exception $e) {}
>
>                 header('Content-Type: text/plain; charset=UTF-8');
>                 echo $res;
>         }
> }
>
> --
> brol
>
> --
> Dev mailing list - [email protected] -
> http://ml.dotclear.org/listinfo/dev
>
-- 
Dev mailing list - [email protected] - http://ml.dotclear.org/listinfo/dev

Répondre à