It was a quick-and-dirty implementation involving adding of a variable into the existing array.
In the config.inc.php file, instead of calling out this function:
Code: Select all
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
I added a block of code that does the same thing, plus accepting a language variable:
Code: Select all
$navlinks = array();
$conf_amount = array(
'var' => 'amount',
'name' => NAVLINK_AMOUNT,
'type' => 'string',
'default' => '5',
'scope' => 'global'
);
$template_config[] = $conf_amount;
if (!isset($template_loaded_config['amount']) || empty($template_loaded_config['amount'])) {
$template_loaded_config['amount'] = $conf_amount['default'];
}
for ($i = 0; $i < $template_loaded_config['amount']; $i++) {
$navlinks[] = array(
'title' => $template_loaded_config['navlink' . $i . 'text'],
'href' => $template_loaded_config['navlink' . $i . 'url'],
'language' => $template_loaded_config['navlink' . $i . 'lang']
);
$template_config[] = array(
'var' => 'navlink' . $i . 'text',
'name' => NAV_LINK_TEXT . ' #' . ($i+1),
'type' => 'string',
'default' => 'Link #' . ($i+1),
'scope' => 'global'
);
$template_config[] = array(
'var' => 'navlink' . $i . 'url',
'name' => NAV_LINK_URL . ' #' . ($i+1),
'type' => 'string',
'default' => '#',
'scope' => 'global'
);
$template_config[] = array(
'var' => 'navlink' . $i . 'lang',
'name' => INSTALL_LANG . ' #' . ($i+1),
'type' => 'select',
'default' => 'all',
'select_values' => array('all' => COMMENTS_FILTER_ALL,
'en' => 'English',
'de' => 'German',
'da' => 'Danish',
'es' => 'Spanish',
'fr' => 'French',
'fi' => 'Finnish',
'cs' => 'Czech (Win-1250)',
'cz' => 'Czech (ISO-8859-2)',
'nl' => 'Dutch',
'is' => 'Icelandic',
'se' => 'Swedish',
'pt' => 'Portuguese Brazilian',
'pt_PT' => 'Portuguese European',
'bg' => 'Bulgarian',
'hu' => 'Hungarian',
'no' => 'Norwegian',
'ro' => 'Romanian',
'it' => 'Italian',
'ru' => 'Russian',
'fa' => 'Persian',
'tw' => 'Traditional Chinese (Big5)',
'tn' => 'Traditional Chinese (UTF-8)',
'zh' => 'Simplified Chinese (GB2312)',
'cn' => 'Simplified Chinese (UTF-8)',
'ja' => 'Japanese',
'ko' => 'Korean'),
'scope' => 'global'
);
}
$serendipity['smarty']->assignByRef('navlinks', $navlinks);
At first, I added the code for the language variable after calling out
serendipity_loadGlobalThemeOptions, but then the dropdown box for the language appeared together at the bottom of the page, so I went with this way.
Then in the index.tpl of the theme, the navbar rendering implements "navlink.language" like so:
Code: Select all
<ul>
{foreach from=$navlinks item="navlink"}
{if $navlink.language!='all'&&$navlink.language!=$lang}
{elseif $navlink.title!=""&&$navlink.href!=""}
<li>
{if $currpage==$navlink.href or $currpage2==$navlink.href}
<span>
{else}
<a href="{$navlink.href}">
{/if}
{$navlink.title}
{if $currpage==$navlink.href or $currpage2==$navlink.href}
</span>
{else}
</a>
{/if}
</li>
{/if}
{/foreach}
</ul>
The initial {if}{elseif} should filter out a menu item if it's not assigned to the correct language.
P.S. The avatar is the dancing badger from the 2003 fiash animation that was quite famous back then.