Recherche intégrée de Yahoo Y!Q
Y!Q can be integrated into any Xanthia theme or pnRender module template. In this example we'll use the news module and integrate the plugin into the full article template of a theme - as shown in the demo. Our original theme template looks like
Y!Q peut être intégré dans n'importe quel thème xanthia ou template de module pnRender. Dans cet exemple nous utiliserons le module de nouvelles et intégrerons le plugin dans le template d'article d'un thème - suivant les indications de la démo. Notre template original de thème aura
<h2><!--[$preformat.catandtitle]--> <small>Filed under <!--[$info.topictext]--> by <!--[$info.informant]--> <!--[$info.time|timeofday]--> of <!--[$info.time|pndate_format:datebrief]--></small> <!--[articleadminlinks sid=$info.sid]--> <div class="entry"> <!--[$info.maintext]--> </div> <p class="postmetadata"><!--[$preformat.notes]--></p> </div>
In the demo we activate the Y!Q search only for the first paragraph or so of the news article. This is achieved by changing the article template to output our 'home text' and 'body text' fields seperately.</p>
Dans la démo nous activons Y!Q Recherche seulement pour le premier paragraphe de l'article de nouvelles. Ceci est réalisé en changeant le template d'article pour produire notre « texte d'accueil » et des champs de « des textes de corps » séparément.</p>
<h2><!--[$preformat.catandtitle]--></h2> <small>Filed under <!--[$info.topictext]--> by <!--[$info.informant]--> <!--[$info.time|timeofday]--> of <!--[$info.time|pndate_format:datebrief]--></small> <!--[articleadminlinks sid=$info.sid]--> <div class="entry"> <!--[$info.hometext]--> <!--[$info.bodytext]--> </div> <p class="postmetadata"><!--[$preformat.notes]--></p> </div>
The next step is to add the Y!Q plugin call to the template. This will show the Y!Q interface and actually allow the search to be performed. The label text in the search button defaults to 'Possibly related stuff'. This can be overriden by passing a label into the plugin e.g. <!--[yq ..... label='related search']-->.
La prochaine étape est d'ajouter l'appel du plugin Y!Q au template. Ceci montrera l'interface Y!Q et permettra réellement à la recherche d'être exécutée. Le label de texte dans le bouton de recherche se transfère sur « la substance probablement reliée ». Ceci peut être overriden en mettant une étiquette dans le plugin par exemple <!--[yq ..... label='related search']-->.
<div class="article-<!--[$info.sid]-->">
<h2><!--[$preformat.catandtitle]--></h2>
<small>Filed under <!--[$info.topictext]--> by <!--[$info.informant]--> <!--[$info.time|timeofday]-->
of <!--[$info.time|pndate_format:datebrief]--></small>
<!--[articleadminlinks sid=$info.sid]-->
<div class="entry">
<!--[yq searchtext2=$info.title searchtext2=$info.hometext]-->
<!--[$info.hometext]-->
<!--[$info.bodytext]-->
</div>
<p class="postmetadata"><!--[$preformat.notes]--></p>
</div>
Our last step, and the reason why we split the home and body text up, is to show the user a visual indicator of what text is being included in the search process. To achive this we wrap this test (the home text) in a div of class 'yqcontext'. This gives us our final template.
Notre dernière étape, est la raison pour laquelle nous dédoublons le texte d'accueil du corps vers le haut, est de montrer à l'utilisateur un indicateur visuel du texte qui a été inclus dans la recherche. Pour réaliser ceci nous enveloppons cet essai (le texte d'accueil) dans une division de classe « yqcontext ». Ceci nous donne notre template final.
<div class="article-<!--[$info.sid]-->">
<h2><!--[$preformat.catandtitle]--></h2>
<small>Filed under <!--[$info.topictext]--> by <!--[$info.informant]--> <!--[$info.time|timeofday]--> of <!--[$info.time|pndate_format:datebrief]--></small>
<!--[articleadminlinks sid=$info.sid]-->
<div class="entry">
<div class="yqcontext">
<!--[yq searchtext2=$info.title searchtext2=$info.hometext]-->
<!--[$info.hometext]-->
</div>
<!--[$info.bodytext]-->
</div>
<p class="postmetadata"><!--[$preformat.notes]--></p>
</div>