News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Language Drop Down

Started by Matthew K., January 02, 2007, 11:41:04 PM

Previous topic - Next topic

sami_sama

can anyone help me plz? i really need this language dropdown to work in my other template

pomak

Hello,  i have got international members and i installed language drop to my portal. it works pretty good but i need to use this mod for my classic theme. How can i do that? Default language of my forum is bulgarian. 
Regards

sawz

Quote from: pomak on April 22, 2007, 08:04:32 AM
Hello,  i have got international members and i installed language drop to my portal. it works pretty good but i need to use this mod for my classic theme. How can i do that? Default language of my forum is bulgarian. 
Regards
you'll have to edit the whatever files need editing for this to work on the classic theme. the mod has an xml file i believe that will tell you what goes where.
keep smiling, they'll always wonder what your up too.....

SleePy

Sorry for the lack or repling. I lost my notifications on this for some reason.
The mod is very easy to add into your theme.

With 1.2 Their is a template for it called template_language_select() that I add to the index.template.php

Add that template function to your custom theme and then just like the menu do a call for it where you want it.
template_language_select();
or
echo template_language_select();
or
echo 'Junk here ', template_language_select(), ' Junk there';

It is very simple.
In the 2 versions before that it was languageDrop() you just needed to add where you wanted it.
This was changed because I was doing templating in the sources and that is against the coding guidelines so I fixed it.

The error about the scripturl
8: Undefined variable: scripturl
I just fixed. I missed a global in the template. I updated the mod as 1.2.1
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

pomak

Blagodarq- Thank you very much. it works  :)
Regards

ChaosEnergy

thanks, the fix for the global works
Chaos Empire ®

sami_sama

thnx alot, it works on my other teme now ^_^

webfritz

Hi, i am stuck in confusion. Some things I understand, but i am not able to integrate the coding in my template at http://www.c-work.de/sql5_tx/index.php 

My questions are:

What is the exact code and in which line I have to integrate?
What's the file to put it in? (according to my template circumstances)

Please help if you can :'( Thanks a lot!

SleePy

The mod makes its own function called template_language_select() in the index.template.php
Add this to your index.template.php and then where you want it to appear in your index.template.php just do template_language_select();
Kinda follows how the template_menu and template_linktree works.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

webfritz

Hi SleePy,

thanks for your response. I hope, together we will get it workin' .. ;D

I guess to have found the snippet in my index.template.php but I am not a sophisticated programmer and need some adds to cope with that:

// Show the menu here, according to the menu sub template.
template_menu();
echo '
</td>
</tr>';

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<tr class="windowbg2">
<td colspan="2" height="24" class="tborder" style="border-width: 1px 0 0 0; padding-left: 1ex;">
<b>', $txt[102], ':</b> ', $context['random_news_line'], '
</td>
</tr>';

echo '
</table>


I want to have it here in my site (check out here) and have a look at the picture and I have added the file index.template.php

SleePy

hmm. just a guess here but try:

// Show the menu here, according to the menu sub template.
template_menu();
echo '
</td>
</tr>';

to:


// Show the menu here, according to the menu sub template.
template_menu();
echo '
</td>
<td>', template_language_select(), '
</td>
</tr>';
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

webfritz

#71
Oops, seems to be a problem in the problem:

QuoteCall to undefined function template_language_select() in /home/www/web531/html/sql5_tx/Sources/Load.php(1726) : eval()'d code on line 158

But, it works with fine with the DMF Default template.  :(

Please, if you get stuck in the snippets above, remember to have the full index.template.pho too.  :)

Added information:
Caches are actually set to OFF !! 8)

SleePy

You need to also add the function to the end of that file just before the ?>

// Generate the Language Drop Down..
function template_language_select()
{
global $context, $txt, $scripturl;

// Do the Function...
languageDrop();

// Hopefully We always have something to show for ourselves.
if (!empty ($context['languages']))
{
echo '
<form action="', $scripturl , !empty($_REQUEST['action']) ? '?action=' . $_REQUEST['action'] . (!empty($_REQUEST['sa']) ? ';sa=' . $_REQUEST['sa'] : '' ) : '', '" method="post" class="smalltext" style="float: right;">
<select id="language_select" name="language" onchange="this.form.submit()" class="smalltext">';
foreach ($context['languages'] as $language)
echo '
<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', $language['name'], '</option>';
echo '
</select><input type="hidden" name="changelang" value="1" />&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
}
// No languages we can find!
elseif (empty ($context['languages']))
echo 'LanguageDrop: ' . $txt[398];
// If this occurs we are in trouble.
else
echo 'LanguageDrop: ' . $txt[106];
}

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

webfritz

#73
Thanks SleePy, that was a Full Pull ! :) I am really happy because it's working perfectly and I can integrate english native speakers! Thanks a lot ! :-* :-*

teff

hey, i have got a problem with the code in my index.template from my theme babylon. can you take a look and say me what is wrong???

www.laxboard.de/smf

the mod works with the standard theme.


SleePy

teff it appears to be working what is the problem?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

teff

yes, now it ist working, i solved the problem last night

joseph21

#77
Hello, could somebody please help make it work for ig-oh blue default theme? I'm trying to place the language drop on the upper right corner beside the SMF Logo.

EDIT: May I know why is it not working for me even in Babylon theme or YaBB theme? I place this codes below on the index.template.php but doesn't show up other than the default.

echo template_language_select(); or
echo languageDrop();

I even place this codes just after the <body> of the index.template.php of babylon
<body>';
echo 'Junk here ', template_language_select(), ' Junk there';

but it gave me this error:
QuoteJunk here
Fatal error: Call to undefined function: template_language_select() in /home/xxx/public_html/forum/Sources/Load.php(1726) : eval()'d code on line 147

Thanks.
SMF 1.1.2 (SMF shop-Ad Management), Joomla 1.0.12, Ortsios Joomla - SMF bridge 1.1.7, CB 1.0.2 and many more..

SleePy

There is also a function you need to add to the index.template.php

// Generate the Language Drop Down..
function template_language_select()
{
global $context, $txt, $scripturl;

// Do the Function...
languageDrop();

// Hopefully We always have something to show for ourselves.
if (!empty ($context['languages']))
{
echo '
<form action="', $scripturl , !empty($_REQUEST['action']) ? '?action=' . $_REQUEST['action'] . (!empty($_REQUEST['sa']) ? ';sa=' . $_REQUEST['sa'] : '' ) : '', '" method="post" class="smalltext" style="float: right;">
<select id="language_select" name="language" onchange="this.form.submit()" class="smalltext">';
foreach ($context['languages'] as $language)
echo '
<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', $language['name'], '</option>';
echo '
</select><input type="hidden" name="changelang" value="1" />&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
}
// No languages we can find!
elseif (empty ($context['languages']))
echo 'LanguageDrop: ' . $txt[398];
// If this occurs we are in trouble.
else
echo 'LanguageDrop: ' . $txt[106];
}
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

joseph21

Thanks sleepy, it works now.  :)
SMF 1.1.2 (SMF shop-Ad Management), Joomla 1.0.12, Ortsios Joomla - SMF bridge 1.1.7, CB 1.0.2 and many more..

Advertisement: