Page 1 of 1

Show News articles in default language when empty

Posted: Tue Aug 31, 2010 11:18 pm
by Dutch_guy
I have three languages.

In my template I call the newsmodule as follows:

{news category="Partners-$lang" summarytemplate="Partners" sortasc="true" }

Not all my languages have translations of the news articles.

How can I show the news articles in the default language when there is no translation in that language ?

I was thinking about the following UDT:

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty(); 
$lang = $smarty->get_template_vars('lang');

  if ($lang == 'nl_NL'){    
      echo 'nl_NL';
  } elseif ($lang == 'en_US')  {
       echo 'en_US';
  }  else  {
       echo 'en_US';
  }
But How to correctly use the UDT in stead of the $lang part:

{news category="Partners-$lang" summarytemplate="Partners" sortasc="true" }

?

Re: Show News articles in default language when empty

Posted: Wed Sep 01, 2010 3:39 pm
by alby
Dutch_guy wrote: But How to correctly use the UDT in stead of the $lang part:
Humm, why UDT...
I think with (in 1.8.2):

Code: Select all

{capture assign="news_language"}{news category="Partners-$lang" summarytemplate="Partners" sortasc="true"}{/capture}
{if $itemcount > 0}{$news_language}
{else}{news category="Partners-$lang_default" summarytemplate="Partners" sortasc="true"}{/if}
Alby

Re: Show News articles in default language when empty

Posted: Wed Sep 01, 2010 6:17 pm
by Dutch_guy
Works !

Thanks !

Do you have any more info on the "capture" code ?

Re: Show News articles in default language when empty

Posted: Thu Sep 02, 2010 9:17 am
by alby
Dutch_guy wrote: Do you have any more info on the "capture" code ?
http://www.smarty.net/manual/en/languag ... on.capture

Alby