RSS feed and language : example

With hookable xili-language plugin, it is possible to create a list with rss for each language. In sidebar, the languages list contains icon for rss and link under each is a link to a rss feed for this language.

One example and extracts with hook xili_language_list in file functions.php of current theme.


xili_language_list() through his third param permit to specify different types of list (here with flag and rss icon).

Extract of fonction xiliml_infunc_language_list :

} elseif ($theoption == 'siderss') {
		if (is_category()) {  
			$catcururl = xiliml_get_category_link();
			$currenturl = $catcururl.'&';
			$cat_ID = $wp_query->query_vars['cat'];
			$currentrss = get_bloginfo('siteurl').'?feed=rss2&cat='.$cat_ID; 
		} else { // home
		 	$currenturl = get_bloginfo('siteurl').'/?';
		 	$currentrss = get_bloginfo('siteurl').'/?feed=rss2';
		$listlanguages = get_terms_of_groups_lite (the_cur_langs_group_id(),TAXOLANGSGROUP,TAXONAME,'ASC');	
		foreach ($listlanguages as $language) {
			if ($language->slug != 'ar_ar' && $language->slug != 'ar_ma') {
				if ($before=='<li>') {
					if (the_curlang() == $language->slug) { 
						$beforee = '<li class="current-cat" >';
					} else {
						$beforee ='<li>';
				$a .= $beforee ."<a href='".$currenturl.QUETAG."=".$language->slug."' title='".__('Posts selected',THEME_TEXTDOMAIN)." ".__('in '.$language->description,THEME_TEXTDOMAIN)."'>"." <img src='".get_bloginfo('template_directory')."/images/flags/".$language->slug.".png' alt='' /> ". __('in '.$language->description,THEME_TEXTDOMAIN) ."</a> <a href='".$currentrss.'&amp;'.QUETAG."=".$language->slug."'><img src='".get_bloginfo('template_directory')."/images/rss.png' alt='rss'/></a>".$after;
		if (is_category()) {
			$currenturl = xiliml_get_category_link();
			$a .= $before."<a href='".$currenturl."' title='".__('Posts of current category in all languages',THEME_TEXTDOMAIN)."' >"." <img src='".get_bloginfo('template_directory')."/images/flags/www.png' alt='' /> ".__('in all languages',THEME_TEXTDOMAIN)."</a> <a href='".$currentrss."'><img src='".get_bloginfo('template_directory')."/images/rss.png' alt='rss'/></a>".$after;
		echo $a;	
	} else {

in sidebar, template tag is :

<ul class="langs">
		<?php if (function_exists('xili_language_list')) {
		} ?>

Caution : to build the link use only default param in code ?feed=…
Link under icon is like – feed:// – and will correctly decoded by the server even if permalink option is activated and will provide good results : a feed in one language for the site or a specific category.

Good coding.

Ce contenu a été publié dans Experts corner, xili-language, avec comme mot(s)-clé(s) , , , , , . Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire