Show News articles in default language when empty

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
Dutch_guy
Forum Members
Forum Members
Posts: 64
Joined: Wed Apr 23, 2008 11:19 am

Show News articles in default language when empty

Post 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" }

?
alby

Re: Show News articles in default language when empty

Post 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
Dutch_guy
Forum Members
Forum Members
Posts: 64
Joined: Wed Apr 23, 2008 11:19 am

Re: Show News articles in default language when empty

Post by Dutch_guy »

Works !

Thanks !

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

Re: Show News articles in default language when empty

Post 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
Locked

Return to “[locked] CMSMS MLE fork”