About new template tags of xili-language plugin

Experts in WordPress, php and html are in habit to read the code of the plugin and have discovered at the end after the xili_language class a list of template tags for inclusion in theme.
This post is a short review of both tags (in plugin or hooked by plugin).
Template tags are sometime included in widgets.
(from time to time, this post will be completed)

Introduction

As described here in codex, WordPress provides infinite ways to enrich core behaviours. The writing adventure for create this plugin, is a permanent research in the hooks catalog and the wordpress source began since version 2.3.
The first research : creating API for current template tags,
The second research : design specific template tags for the plugin itself or to replace unadapted tags of WordPress core.
The results are in the 2 others tabs of this post…

New template tags

Specific template tags :

1) The list of current available languages of the website :
xili_language_list($before = '<li>', $after ='</li>', $theoption='')

On this site, it is inserted in top menu (the flags), in sidebar (through widget).

2) For one post, it gives the list of linked posts in other language about this subject :
xiliml_the_other_posts ($post_ID,$before = "This post in", $separator = ", ")

In single full post, it is visible (if possible) under the title.

3) Template Tag insertable in search form for sub-selection of a language
xiliml_langinsearchform ($before='',$after='')

Sometime, hooks are lacking, so some new tags were designed.

a) The translated list of categories of a post (replace the_category()) :
xiliml_the_category($post_ID, $separator = ', ' ,$echo = true)

More details are present in the plugin code before each function.

Template tags "hooked" by xili-language

Here below a list a template tags which are « modified » in their display results by xili-language :

1) Categories list

Through 3 hooks, the categories list

wp_list_categories();

display translated name, description and link (as visible here on the right).

2) Archives month list

Archives tags is a very complex template tag in his background and not very easy hookable source. So we decided to add few features : by adding query in vars of the function, it will be possible to display a monthly list of archives for a selected language

wp_get_archives('..your.vars..&lang=fr_fr')

or the current the theme language

wp_get_archives('..your.vars..&lang=')

The displayed list of links will be translated and link restricted to display only archives of this language.

3) Pages list :

When xili-language is activated, the template tag is able to use « lang » query tag :
* example 1 :

wp_list_pages('title_li=&lang='.the_curlang() );

will display only pages of current lang
* example 2 :

wp_list_pages('title_li=&setlang=0&lang='.the_curlang() );

will display pages of current lang AND pages with lang undefined (polyglot pages).

As described in the plugin’s php code, most of the methods and functions can also be « hooked ». It is an open way to personalize your CMS site with very accurate features. A future post is on the way ! M. 090605
Ce contenu a été publié dans Experts corner, xili-language. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire