Language Button Menu

Started by navarretemarce, October 01, 2010, 12:18:54 PM

Previous topic - Next topic

liuxyon

it is can't worK in SMF2.0.2 defualt theme  and meridian theme.


I can't find the code in  index.template.php file.

<div id="upper_section" class="middletext"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>


How I fix it now?

my meridian theme index.template.php file  is:




<?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines
 * @copyright 2011 Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.0
 */

/* This template is, perhaps, the most important template in the theme. It
contains the main template layer that displays the header and footer of
the forum, namely with main_above and main_below. It also contains the
menu sub template, which appropriately displays the menu; the init sub
template, which is there to set the theme up; (init can be missing.) and
the linktree sub template, which sorts out the link tree.

The init sub template should load any data and set any hardcoded options.

The main_above sub template is what is shown above the main content, and
should contain anything that should be shown up there.

The main_below sub template, conversely, is shown after the main content.
It should probably contain the copyright statement and some other things.

The linktree sub template should display the link tree, using the data
in the $context['linktree'] variable.

The menu sub template should display all the relevant buttons the user
wants and or needs.

For more information on the templating system, please see the site at:
http://www.simplemachines.org/
*/

// Initialize the template... mainly little settings.
function template_init()
{
global $context$settings$options$txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '2.0';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as opposed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status separate from topic icons? */
$settings['separate_sticky_lock'] = true;

/* Does this theme use the strict doctype? */
$settings['strict_doctype'] = false;

/* Does this theme use post previews on the message index? */
$settings['message_index_preview'] = false;

/* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */
$settings['require_theme_strings'] = true;
}

// The main sub template above the content.
function template_html_above()
{
global $context$settings$options$scripturl$txt$modSettings;

// Show right to left and the character set for ease of translating.
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''>
<head>'
;

// The ?fin20 part of this link is just here to make sure browsers don't cache it wrongly.
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/index'$context['theme_variant'], '.css?fin20" />';

// Some browsers need an extra stylesheet due to bugs/compatibility issues.
foreach (array('ie7''ie6''webkit') as $cssfix)
if ($context['browser']['is_' $cssfix])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/css/'$cssfix'.css" />';
    
//If search box enabled, connect some styles.
if (!empty($settings['search_box'])) 
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/search_box_enabled.css" />';
else 
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/search_box_disabled.css" />';
// RTL languages require an additional stylesheet.
if ($context['right_to_left'])
echo '
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/rtl.css" />';

// Here comes the JavaScript bits!
echo '
<script type="text/javascript" src="'
$settings['default_theme_url'], '/scripts/script.js?fin20"></script>
<script type="text/javascript" src="'
$settings['theme_url'], '/scripts/theme.js?fin20"></script>';

if (!empty($settings['jquery']))
    echo 
'
<script type="text/javascript" src="'
$settings['theme_url'], '/scripts/jquery.js?fin20"></script>';

if (!empty($settings['gradualfader']))
echo '
<script type="text/javascript"><!-- // --><![CDATA[
    $(document).ready(function(){
$(".quickbuttons li, #search_box_sub, .logout_image").fadeTo(1500, 0.5);
$(".quickbuttons li, #search_box_sub, .logout_image").hover(function(){
$(this).stop().fadeTo("fast", 1.0);
},function(){
    $(this).stop().fadeTo("fast", 0.5);
});
});
// ]]></script>'
;
echo '
<script type="text/javascript"><!-- // --><![CDATA[
var smf_theme_url = "'
$settings['theme_url'], '";
var smf_default_theme_url = "'
$settings['default_theme_url'], '";
var smf_images_url = "'
$settings['images_url'], '";
var smf_scripturl = "'
$scripturl'";
var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
var smf_charset = "'
$context['character_set'], '";'$context['show_pm_popup'] ? '
var fPmPopup = function ()
{
if (confirm("' 
$txt['show_personal_messages'] . '"))
window.open(smf_prepareScriptUrl(smf_scripturl) + "action=pm");
}
addLoadEvent(fPmPopup);' 
'''
var ajax_notification_text = "'
$txt['ajax_in_progress'], '";
var ajax_notification_cancel_text = "'
$txt['modify_cancel'], '";
// ]]></script>'
;

echo '
<meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
<meta name="description" content="'
$context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
<meta name="keywords" content="' 
$context['meta_keywords'] . '" />' '''
<title>'
$context['page_title_html_safe'], '</title>';

// Please don't index these Mr Robot.
if (!empty($context['robot_no_index']))
echo '
<meta name="robots" content="noindex" />'
;

// Present a canonical url for search engines to prevent duplicate content in their indices.
if (!empty($context['canonical_url']))
echo '
<link rel="canonical" href="'
$context['canonical_url'], '" />';

// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="'
$scripturl'?action=help" />
<link rel="search" href="'
$scripturl'?action=search" />
<link rel="contents" href="'
$scripturl'" />';

// If RSS feeds are enabled, advertise the presence of one.
if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
echo '
<link rel="alternate" type="application/rss+xml" title="'
$context['forum_name_html_safe'], ' - '$txt['rss'], '" href="'$scripturl'?type=rss;action=.xml" />';

// If we're viewing a topic, these should be the previous and next topics, respectively.
if (!empty($context['current_topic']))
echo '
<link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
<link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board']))
echo '
<link rel="index" href="'
$scripturl'?board='$context['current_board'], '.0" />';

// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'];

echo '
</head>
<body>'
;
}

function 
template_body_above()
{
global $context$settings$options$scripturl$txt$modSettings;

echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' 
$settings['forum_width'] . '">' '''
    <div class="top_block">
  <div class="user_block">'
;

if ($context['user']['is_logged']) 
{
   if ($settings['enable_unread_replies'])
    echo '
<div class="floatleft">&bull; <a href="'
$scripturl'?action=unread">'$txt['unread_since_visit'], '</a> | <a href="'$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a></div>';
    else 
 echo '
    <div class="floatleft"> &bull; '
$context['current_time'], '</div>';
}
else 
    echo '
    <div class="floatleft"> &bull; '
$context['current_time'], '</div>';

if ($context['user']['is_logged'])
{
echo 
'
    <a href="'
$scripturl '?action=logout;'$context['session_var'], '='$context['session_id'] ,'"><img class="logout_image" src="'$settings['images_url'], '/logout.png" title="'$txt['logout'] ,'" alt="" /></a>';
echo '
<div class="floatright">
&bull; '
$txt['hello_member_ndt'], ' <a href="'$scripturl'?action=profile"><span>'$context['user']['name'], '</span></a>';
if($context['allow_admin']) {
echo '
<a class="admin_href" href="'
$scripturl'?action=admin">' ,$txt['admin'], '</a>';
}
        if(
$context['allow_moderation_center']) {
echo '
<a class="moder_href" href="'
$scripturl'?action=moderate">' ,$txt['moderate'], '</a>';
}

echo '
</div>'
;

}
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
else
    {
echo '
<div class="floatright">&bull;  '
sprintf($txt['welcome_guest'], $txt['guest_title']), '</div>';
    }

echo '
    <div class="clear"></div>
  </div>
  <div class="logo_bg">
    <div class="floatleft logo_img"><a href="'
$scripturl'">';

// If user need custom logo - add image.
if (!empty($settings['header_logo_url']))
echo '
<img src="'
$settings['header_logo_url'], '" class="floatleft"  alt="' $context['forum_name'] . '" /></a></div>';
else 
echo '<img src="'$settings['images_url'], '/logo.png" class="floatleft"  alt="' $context['forum_name'] . '" /></a></div>';

// Forum name or slogan?
echo '
    <div class="floatleft logo"><a href="'
$scripturl'">', empty($settings['site_slogan']) ? '' $context['forum_name']  :  $settings['site_slogan'] . '' ,'</a></div>';
if (!empty($settings['top_right_code']))  {
       echo 
'
    <div class="floatright banner_top">'
$settings['top_right_code'] , '</div>';
    }



echo '
  <div class="clear"></div>
  </div>
</div>
<div id="header"><div class="frame">'
;

// Show the menu here, according to the menu sub template.
template_menu();


echo '
<div class="clear"></div>
</div></div>'
;

// The main content should go here.
echo '
<div id="content_section"><div class="frame">
<div id="main_content_section">'
;
   
   
   
// search box(absolute position)
   
if (!empty($settings['search_box'])) {
echo '
<div class="search_bg">
<form id="search_form" action="'
$scripturl'?action=search2" method="post" accept-charset="'$context['character_set'], '">
<input type="text" name="search" value="" class="input_text" id="search_box_in" />&nbsp;
<input type="image" src="'
$settings['images_url'], '/search_box_sub.png" name="submit" class="gradualfader" id="search_box_sub" />
<input type="hidden" name="advanced" value="0" />'
;

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="'
$context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd['
$context['current_board'], ']" value="'$context['current_board'], '" />';

echo '</form>
</div>'
;
}

if ($context['user']['is_logged'])
{

  // Is the forum in maintenance mode?
  if ($context['in_maintenance'] && $context['user']['is_admin'])
  echo '
<span class="notice">&bull;&nbsp;'
$txt['maintain_mode_on'], '</span><br />';
      
// Are there any members waiting for approval?
  if (!empty($context['unapproved_members']))
echo '
&bull;&nbsp;'
$context['unapproved_members'] == $txt['approve_thereis'] : $txt['approve_thereare'], ' <a href="'$scripturl'?action=admin;area=viewmembers;sa=browse;type=approve">'$context['unapproved_members'] == $txt['approve_member'] : $context['unapproved_members'] . ' ' $txt['approve_members'], '</a> '$txt['approve_members_waiting'], '';

  if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
echo '
&bull;&nbsp;<a href="'
$scripturl'?action=moderate;area=reports">'sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '</a>';

}
// Show a random news item? (or you could pick one from news_lines...)    
if (!empty($settings['enable_news']))
echo '
      <div class="news_box">
    <img src="'
$settings['images_url'], '/news.png" class="news_box_img" alt="" />
<span class="topslice"><span></span></span>
<div><b>'
$txt['news'], '</b>: '$context['random_news_line'], '</div>
        <span class="botslice"><span></span></span>
  </div>'
;

// Custom banners and shoutboxes should be placed here, before the linktree.

// Show the navigation tree.
theme_linktree();
}

function 
template_body_below()
{
global $context$settings$options$scripturl$txt$modSettings;

echo '
</div>
</div></div>'
;

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
echo '
<div id="footer_section"><div class="frame">
<ul class="reset">
<li class="copyright">'
theme_copyright(), '</li>
<li><a id="button_xhtml" href="http://validator.w3.org/check?uri=referer" target="_blank" class="new_win" title="'
$txt['valid_xhtml'], '"><span>'$txt['xhtml'], '</span></a></li>
'
, !empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']) ? '<li><a id="button_rss" href="' $scripturl '?action=.xml;type=rss" class="new_win"><span>' $txt['rss'] . '</span></a></li>' '''
<li class="last"><a id="button_wap2" href="'
$scripturl '?wap2" class="new_win"><span>'$txt['wap2'], '</span></a></li>
<li class="copyright"><a href="http://custom.simplemachines.org/themes/index.php?lemma=2576">Meridian theme</a></li>
</ul>'
;

// Show the load time?
if ($context['show_load_time'])
echo '
<p>'
$txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';

echo '
</div></div>'
, !empty($settings['forum_width']) ? '
</div>' 
'';
}

function 
template_html_below()
{
global $context$settings$options$scripturl$txt$modSettings;

echo '
</body></html>'
;
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show false)
{
global $context$settings$options$scripturl$txt$shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;

echo '
<div class="nav_box">
<img src="'
$settings['images_url'], '/nav.png" class="nav_box_img" alt="" />
<span class="upperframe"><span></span></span>
<div class="navigate_section roundframe">
<ul>'
;

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li'
, ($link_num == count($context['linktree']) - 1) ? ' class="last"' '''>';

// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' 
$tree['url'] . '"><span>' $tree['name'] . '</span></a>' '<span>' $tree['name'] . '</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo ' &#38;#187;';

echo '
</li>'
;
}
echo '
</ul>
</div>
<span class="lowerframe"><span></span></span>
</div>'
;

$shown_linktree true;
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context$settings$options$scripturl$txt;

echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">'
;

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_'
$act'">
<a class="'
$button['active_button'] ? 'active ' '''firstlevel" href="'$button['href'], '"', isset($button['target']) ? ' target="' $button['target'] . '"' '''>
<span class="'
, isset($button['is_last']) ? 'last ' '''firstlevel">'$button['title'], '</span>
</a>'
;
if (!empty($button['sub_buttons']))
{
echo '
<ul>'
;

foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li>
<a href="'
$childbutton['href'], '"', isset($childbutton['target']) ? ' target="' $childbutton['target'] . '"' '''>
<span'
, isset($childbutton['is_last']) ? ' class="last"' '''>'$childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' '''</span>
</a>'
;
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{
echo '
<ul>'
;

foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a href="'
$grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' $grandchildbutton['target'] . '"' '''>
<span'
, isset($grandchildbutton['is_last']) ? ' class="last"' '''>'$grandchildbutton['title'], '</span>
</a>
</li>'
;

echo '
</ul>'
;
}

echo '
</li>'
;
}
echo '
</ul>'
;
}
echo '
</li>'
;
}

echo '
</ul>
</div>'
;
}

// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$strip_options = array())
{
global $settings$context$txt$scripturl;

if (!is_array($strip_options))
$strip_options = array();

// List the buttons in reverse order for RTL languages.
if ($context['right_to_left'])
$button_strip array_reverse($button_striptrue);

// Create the buttons...
$buttons = array();
foreach ($button_strip as $key => $value)
{
if (!isset($value['test']) || !empty($context[$value['test']]))
$buttons[] = '
<li><a' 
. (isset($value['id']) ? ' id="button_strip_' $value['id'] . '"' '') . ' class="button_strip_' $key . (isset($value['active']) ? ' active' '') . '" href="' $value['url'] . '"' . (isset($value['custom']) ? ' ' $value['custom'] : '') . '><span>' $txt[$value['text']] . '</span></a></li>';
}

// No buttons? No button strip either.
if (empty($buttons))
return;

// Make the last one, as easy as possible.
$buttons[count($buttons) - 1] = str_replace('<span>''<span class="last">'$buttons[count($buttons) - 1]);

echo '
<div class="buttonlist'
, !empty($direction) ? ' float' $direction '''"', (empty($buttons) ? ' style="display: none;"' ''), (!empty($strip_options['id']) ? ' id="' $strip_options['id'] . '"'''), '>
<ul>'
,
implode(''$buttons), '
</ul>
</div>'
;
}

?>



navarretemarce

I have updated the mod, cleaned and improved the code. There is a major change and the mode works with integration hooks now. Therefore do not introduces changes in the source code of SMF.
I ask all users to uninstall previous versions and update to the version 3.0. It should work now with SMF 2.02.
For users requiring the implementation on custom themes the following code should be inserted WITHIN the HTML code in the division you want to place the Language Menu:


<div id="language_menu_wrapper">';
        if(function_exists('show_language_menu')) show_language_menu();
        echo'
        </div>


For styling the looks and feel of the menu you can adapt the example .CSS file provided with the mod:


/***************************************
START LANGUAGE MENU STYLES
***************************************/
/*The main language button menu container*/
#language_menu_wrapper {
    margin: 0;
    padding: 0;
}   
#language_menu {
position: relative;
display: inline;
float: right;
padding: 10px;
}
/*Make the buttons align horizontaly*/
#language_menu form {
padding: 0;   
display: inline;
}
/* Pointer to easly identify "clickable" buttons */
#language_menu form button {
font-size:10px;
cursor: pointer;
}
/* Default cursor and different color for distinction of current language */
#language_menu form button.active {
color: #666;
cursor: default;
}
#language_menu img.langicon {
padding-right: 4px;
float: left;
margin-top: 2px;
}
#language_menu button.langflagbutton {
background: none;
border:none;
padding: 0;
margin:0;
opacity: 0.5;
}
#language_menu button.langflagbutton:hover {
opacity: 1;
}
#language_menu button.langflagbuttonactive {
background: none;
border:none;
padding: 0;
margin:0;
cursor: default;
opacity: 1;
}
/***************************************
END LANGUAGE MENU STYLES
***************************************
/

navarretemarce

If you need help placing the menu in your template, please link your live/test site and i will be happy to assist you.

Tina11

#43
Hello,

I have problems to find the right code position in the index.template.php of the theme Epic.

In a one year old forum is the mod version 2.2 installed, were the code piece  show_language_menu();  is added in row 312 of the index.template.php (in the extract here it's in row 6).

global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
<div id="header">
  <div id="userarea" class="smalltext">';
  show_language_menu();
if ($context['user']['is_logged']){
echo '
  <ul class="reset">
<li class="greeting"><strong>', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></strong></li>';
echo '
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>
<li>', $context['current_time'],'</li>
</ul>';}



In the default theme all is perfect, but in the Epic the language menu is not just in one row, it's divided in two rows (even if I use the flag icons or the button menu):


Where is the error there?


I've installed a test forum now (smf 2.0.3) and the newest version of your mod (3.0.1).
With the default theme all works fine but with the Epic theme I have nearly the same problem like in the other forum.
I can't find the right postion for the  language_menu_wrapper  in the index.template.php of the Epic theme.

Can you help me, please? I'm looking already since a long time for a solution, but alone I can't find it.


Best wishes and Merry Christmas/Feliz Navidad from Germany,
Martina

navarretemarce

Hi Martina,

There is actually no error in the code. I only added the if(funcionexsist) statement to improve reliability and prevent page errors if the mod get corrupted or damaged.

the code would more properly be: global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
<div id="header">
  <div id="userarea" class="smalltext">
  <div id="language_menu_wrapper">';
        if(function_exists('show_language_menu')) show_language_menu();
        echo'
        </div>';
if ($context['user']['is_logged']){
echo '
  <ul class="reset">
<li class="greeting"><strong>', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></strong></li>';
echo '
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>
<li>', $context['current_time'],'</li>
</ul>';}


The issue you are experiencing is however css related. The epic theme limits the space dedicated for user area to 38 em. Please use the code above and check if the addition of the new division "language_menu_wrapper" fix it. If not should be easy to fix through css. If you dont know how to do it, provide me a link (here or pm) to your demo site and I will be able to help you with the css.

Greetings,

Marcelo

Tina11

#45
Hi Marcelo,

I used the code but nothing has changed. Than I increased in the index.css the 38em of the user area up to 45, 50 and 60em, but that also didn't helped. Than I tried it with 50% and 350px but this was also unsuccessful.

In all three variants of the menu appear line breaks and the buttons or flags are below each other:



Seemingly as a newbie here in this forum I'm not allowed to add links in the postings, so I wrote them with a blank
character after the http://  !!

My older forum where version 2.2 of the language menu is installed:
http:// forum.lars-mikkelsen.de

The new test forum with version 3.0.1:
http:// forum-test.william-fichtner.de


Greetings,
Martina

navarretemarce

Hi Martina,

took me a wile but i fund the issue. The problem is a parse error in the css file of the epic theme. There is a tag finishing with ) instesd of }.
You need to manually edit the css file of your custom theme.
search for .inputs {
background: #1e1e1e !important;
border-top: 1px solid #000000;
border-right: 1px solid #454545;
border-bottom: 1px solid #454545;
border-left: 1px solid #000000;
color: #c9c9c9;
font-size: 90%;
padding: 2px;
)


replace the last parenthesis ")" for a bracket "}"

The code should look now:
.inputs {
background: #1e1e1e !important;
border-top: 1px solid #000000;
border-right: 1px solid #454545;
border-bottom: 1px solid #454545;
border-left: 1px solid #000000;
color: #c9c9c9;
font-size: 90%;
padding: 2px;
}


Can you contact the author of the Theme to let him/her known about this bug? then she/he can fix it in the next release.

Happy Holidays!

Tina11

Hi Marcelo,

I've replaced the parenthesis for a bracket and the language menu is in one row now - but now the login area is sliped out of its position:

Logged out status:



Logged in status:



Must I add a line break somewhere after the menu code in the index.template.php?


Quote from: navarretemarce on December 28, 2012, 06:27:37 AM
Can you contact the author of the Theme to let him/her known about this bug? then she/he can fix it in the next release.
Yes, I will do it.


Bye,
Martina

navarretemarce

#48
Hi Martina,

The index-template file is fine and should not be edited any more. The code is bug-free now.
The menu is displayed properly, the problem is that there is not room enough in the user area to show the login and the menu within the black area. You have to decide how do you want to distribute the elements. You can:

1.- make login and menu smaller to allow both to show up in the user area (bad idea)
2.- Shift the language menu to the center and allow the login area to stay in the left region or vice-versa

for the second option just go to the index.css file and search for:

#language_menu_wrapper {
    margin: 0;
    padding: 0;
}


and use instead
#language_menu_wrapper {
    margin: 0;
    padding: 0;
    float: left;
}


I think flag icons will look better in this case

Tina11

Hi Marcelo,

I found a solution that the menu and the login area can both stay on the right.
I just added three < /br> in two sections of the index.template.php.

Here (about in the middle):
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
<div id="header">
  <div id="userarea" class="smalltext">';
  show_language_menu();
if ($context['user']['is_logged']){
echo '
  <br /><br /><br /><ul class="reset">
<li class="greeting"><strong>', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></strong></li>';
echo '
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>
<li>', $context['current_time'],'</li>
</ul>';}



And here (at the top):
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
        <br /><br /><br />
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">', $txt['login_or_register'], '</div>
<input type="text" name="user" class="inputs" size="10" />
<input type="password" name="passwrd" style="background: #505050; color: #c9c9c9; border-top: 1px solid #000000; border-right: 1px solid #454545; border-bottom: 1px solid #454545; border-left: 1px solid #000000; font-size: 90%; padding: 2px;" size="10" />
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />';

if (!empty($modSettings['enableOpenID']))
echo '
<br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />';

echo '
<input type="hidden" name="hash_passwrd" value="" />
</form>';
  }
echo '
  </div>';



My last question:
Is there a way to arrange the flag icons in another order than the automatically arranged one?
Has it something to do with the order in which the languages were installed in the forum?

I wish you a happy new year. :)
Martina

error_2

Hi,

I have installed some languages to my forum. I need to re-order the languages. Is there a way to do it?

I have found the problem is here:

LanguageMenu.php

function show_language_menu()
{
   global $context, $txt, $scripturl, $modSettings, $smcFunc, $settings;

   if ($modSettings['language_menu_activate'] == 1)
   {
   // Obtain our languages
   if (empty($context['languages']))


where is it populated? $context['languages']

how to sort this?

navarretemarce

@error_2 : the array $context is a system variable. In order to be minimally intrusive the mod works now relying in system defined variables and integration hooks. A sorting capability will require to store some system variables in new ones and additional coding.
I do not have the time to do it in the immediate future. I will, however, take note of the function request for an eventual new version. 

error_2

Thank you.

It wold be good for smf to make it possible inside the smf system.

Mr. Jinx

#53
Thanks for this mod navarretemarce! This was very usefull for my forum.
Switching between languages is a bit slow though. I'll have to look into that. Any clues?

update: I noticed that the language is changed for *all* users! That's why it was so slow.
It must go wrong in Subs-LangueafMenu.php:
updateMemberData($user_info['id'], array('lngfile' => $_POST['languagemenu']));

If the user id in updateMemberData is empty, all users will be modified.
I don't know yet why $user_info['id'] is empty?

Mr. Jinx

Could someone point me to the right direction please?

In Subs-LanguageMenu.php the function 'updateMemberData' is called.
However, $user_info['id'] is always empty, so it is modifying all users instead of just one.
global $context and $user_info are set.

If I echo $user_info['id'] it is empty...?

navarretemarce

Thank you Mr. Jinx,

I will have a look on that ASAP.. I'm buried on work these days

Mr. Jinx

Ah work, take your time :)

I think you are using the wrong hook for the function "LanguageMenu_Language_Checks"
The hook you used is "integrate_verify_user". This hook will call the "LanguageMenu_Language_Checks" function just before loadUserSettings() in Load.php.
That's probably why $user_info is empty.

glennmckenna

hi I've installed the mod add my host I giving me this error  at the top of the page
QuoteNotice: Undefined index: id in /home/a4787346/public_html/new/forum/Sources/Subs-LanguageMenu.php on line 53

here is a copy of the script that it's talking about
<?php
/**
 * Language Menu for SMF (LMSMF)
 *
 * @package LMSMF
 * @author [Marcelo]
 * @2nd-author emanuele
 * @copyright 2012 [Marcelo], Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 3.0.1
 */
/**********************************************************************************
* LanguageMenu                                                                *
***********************************************************************************
* A modification to show an advanced language menu written for                    *
* SMF: Simple Machines Forum                                                      *
* =============================================================================== *
* Software Version:       LanguageMenu 3.01                                     *
* Software by:            Marcelo Navarrete (http://iluminandoclasicas.com.ar)    *
* Copyright by:           IluminandoClasicsas (http://iluminandoclasicas.com.ar)  *
* Support, News, Updates at: http://www.simplemachines.org                        *
***********************************************************************************

***********************************************************************************
* IMPORTANT!!!!!!:                                                                *
***********************************************************************************
* We kindly ask you to keep the language icon that identify the choose/select     *
* or switch option for languageLanguage Menu.                                     *
* This language icon is an initiative to standardise language selection icon.     *
* If you feel that the size or the default color of the language icon doesn't fit *
* with your theme: at http://www.languageicon.org/index-icon.php you can download *
* any of the language icons free, choose from 61 different colors and styles.     *
* You are using this software for free please help to standarize the              *
* language icon, keeping it in your site. :)                                      *
***********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');
    
function 
LanguageMenu_Language_Checks ()
{
    global 
$context$user_info

    
// Language Checking.
if (isset($_POST['languagemenu']))
{
if (empty($context['languages']))
$languages getLanguages();

if (isset($languages[$_POST['languagemenu']]))
{
updateMemberData($user_info['id'], array('lngfile' => $_POST['languagemenu']));
$user_info['language'] = $_POST['languagemenu'];
$_SESSION['language'] = $_POST['languagemenu'];
}
}
}
   
function 
show_language_menu()
{
global $context$txt$scripturl$modSettings$smcFunc$settings;

//Load language $txt strings
    
loadLanguage('LanguageMenu/LanguageMenu');
    
if ($modSettings['language_menu_activate'] == 1)
{
// Obtain our languages
if (empty($context['languages']))
getLanguages();
// And then our labels 
        
foreach ($context['languages'] as $temp)         
        {
        if (!empty (
$modSettings['lang_menu_label_'.$temp['filename']])) $custom_label [$temp['filename']] = $modSettings['lang_menu_label_'.$temp['filename']];
        }
    
// Do we want custom labels?   
    
if (empty($modSettings['language_menu_activate_custom_labels'])) unset($custom_label);   

// Hopefully We always have something to show  
if (!empty ($context['languages']))
{
echo'
<div id="language_menu">
<img class="langicon" src="'
$settings['default_theme_url'], '/images/LanguageMenuImg/langicon.png" height="16px" width="16px" alt=" " />';
// Do we want a drop language menu?
if ($modSettings['language_menu_tamplate'] == 'drop_menu')
{
echo $txt['language_menu_select_language'], '
<form action="" method="post">
<select id="language_select" name="languagemenu" onchange="this.form.submit()">'
;
foreach ($context['languages'] as $language)
                {
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<option value="'
$language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' '''>' ,$language_button'</option>';
}
echo'
</select><input type="hidden" name="changelang" value="1" />
<noscript><input type="submit" value="'
$txt['quick_mod_go'], '" /></noscript>
</form>'
;
}
// Or perhaps a nice flag icon menu?
elseif ($modSettings['language_menu_tamplate'] == 'icon_menu')
{
foreach ($context['languages'] as $language)
{
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<form action="" method="post">
<input type="hidden" name="languagemenu" value="'
$language['filename'], '" />
<button id="'
$language['filename'], '" type="submit" value="'$language['name'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' disabled="disabled" class="langflagbuttonactive" ' ' class="langflagbutton"''>
  <img class="langflag" src="'
$settings['default_theme_url'], '/images/LanguageMenuImg/'$language['filename'], '.png" height="' ,$modSettings['language_menu_icon_height'], '" width="' ,$modSettings['language_menu_icon_width'], '" alt="' ,$language_button'" /></button>
</form>'
;
}
}
// Ok I got it you want normal buttons... is your choice
elseif ($modSettings['language_menu_tamplate'] == 'button_menu')
{
echo $txt['language_menu_select_language'];
foreach ($context['languages'] as $language)
{
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<form action="" method="post">
<input type="hidden" name="languagemenu" value="'
$language['filename'], '" />
<button id="'
$language['filename'], '" type="submit" value="'$language['name'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' disabled="disabled" class="active" ' '''>' ,$language_button'</button>
</form>'
;
}
}
// Mmmmm we have a problem here
else echo $txt['language_menu_template_error'];
echo'
</div>'
;
}
// No languages we can find!
elseif (empty ($context['languages']))
echo $txt['language_menu'] . $txt['no_matches'];
// If this occurs we are in trouble.
else
echo $txt['language_menu'] . $txt['error_occured'];
   }
}
?>

any help would be much appreciated

glennmckenna

Quote from: glennmckenna on May 01, 2013, 10:35:04 AM
hi I've installed the mod add my host I giving me this error  at the top of the page
QuoteNotice: Undefined index: id in /home/a4787346/public_html/new/forum/Sources/Subs-LanguageMenu.php on line 53

here is a copy of the script that it's talking about
<?php
/**
 * Language Menu for SMF (LMSMF)
 *
 * @package LMSMF
 * @author [Marcelo]
 * @2nd-author emanuele
 * @copyright 2012 [Marcelo], Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 3.0.1
 */
/**********************************************************************************
* LanguageMenu                                                                *
***********************************************************************************
* A modification to show an advanced language menu written for                    *
* SMF: Simple Machines Forum                                                      *
* =============================================================================== *
* Software Version:       LanguageMenu 3.01                                     *
* Software by:            Marcelo Navarrete (http://iluminandoclasicas.com.ar)    *
* Copyright by:           IluminandoClasicsas (http://iluminandoclasicas.com.ar)  *
* Support, News, Updates at: http://www.simplemachines.org                        *
***********************************************************************************

***********************************************************************************
* IMPORTANT!!!!!!:                                                                *
***********************************************************************************
* We kindly ask you to keep the language icon that identify the choose/select     *
* or switch option for languageLanguage Menu.                                     *
* This language icon is an initiative to standardise language selection icon.     *
* If you feel that the size or the default color of the language icon doesn't fit *
* with your theme: at http://www.languageicon.org/index-icon.php you can download *
* any of the language icons free, choose from 61 different colors and styles.     *
* You are using this software for free please help to standarize the              *
* language icon, keeping it in your site. :)                                      *
***********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');
    
function 
LanguageMenu_Language_Checks ()
{
    global 
$context$user_info

    
// Language Checking.
if (isset($_POST['languagemenu']))
{
if (empty($context['languages']))
$languages getLanguages();

if (isset($languages[$_POST['languagemenu']]))
{
updateMemberData($user_info['id'], array('lngfile' => $_POST['languagemenu']));
$user_info['language'] = $_POST['languagemenu'];
$_SESSION['language'] = $_POST['languagemenu'];
}
}
}
   
function 
show_language_menu()
{
global $context$txt$scripturl$modSettings$smcFunc$settings;

//Load language $txt strings
    
loadLanguage('LanguageMenu/LanguageMenu');
    
if ($modSettings['language_menu_activate'] == 1)
{
// Obtain our languages
if (empty($context['languages']))
getLanguages();
// And then our labels 
        
foreach ($context['languages'] as $temp)         
        {
        if (!empty (
$modSettings['lang_menu_label_'.$temp['filename']])) $custom_label [$temp['filename']] = $modSettings['lang_menu_label_'.$temp['filename']];
        }
    
// Do we want custom labels?   
    
if (empty($modSettings['language_menu_activate_custom_labels'])) unset($custom_label);   

// Hopefully We always have something to show  
if (!empty ($context['languages']))
{
echo'
<div id="language_menu">
<img class="langicon" src="'
$settings['default_theme_url'], '/images/LanguageMenuImg/langicon.png" height="16px" width="16px" alt=" " />';
// Do we want a drop language menu?
if ($modSettings['language_menu_tamplate'] == 'drop_menu')
{
echo $txt['language_menu_select_language'], '
<form action="" method="post">
<select id="language_select" name="languagemenu" onchange="this.form.submit()">'
;
foreach ($context['languages'] as $language)
                {
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<option value="'
$language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' '''>' ,$language_button'</option>';
}
echo'
</select><input type="hidden" name="changelang" value="1" />
<noscript><input type="submit" value="'
$txt['quick_mod_go'], '" /></noscript>
</form>'
;
}
// Or perhaps a nice flag icon menu?
elseif ($modSettings['language_menu_tamplate'] == 'icon_menu')
{
foreach ($context['languages'] as $language)
{
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<form action="" method="post">
<input type="hidden" name="languagemenu" value="'
$language['filename'], '" />
<button id="'
$language['filename'], '" type="submit" value="'$language['name'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' disabled="disabled" class="langflagbuttonactive" ' ' class="langflagbutton"''>
  <img class="langflag" src="'
$settings['default_theme_url'], '/images/LanguageMenuImg/'$language['filename'], '.png" height="' ,$modSettings['language_menu_icon_height'], '" width="' ,$modSettings['language_menu_icon_width'], '" alt="' ,$language_button'" /></button>
</form>'
;
}
}
// Ok I got it you want normal buttons... is your choice
elseif ($modSettings['language_menu_tamplate'] == 'button_menu')
{
echo $txt['language_menu_select_language'];
foreach ($context['languages'] as $language)
{
$language_button str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button $custom_label[$language['filename']]; 
echo '
<form action="" method="post">
<input type="hidden" name="languagemenu" value="'
$language['filename'], '" />
<button id="'
$language['filename'], '" type="submit" value="'$language['name'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' disabled="disabled" class="active" ' '''>' ,$language_button'</button>
</form>'
;
}
}
// Mmmmm we have a problem here
else echo $txt['language_menu_template_error'];
echo'
</div>'
;
}
// No languages we can find!
elseif (empty ($context['languages']))
echo $txt['language_menu'] . $txt['no_matches'];
// If this occurs we are in trouble.
else
echo $txt['language_menu'] . $txt['error_occured'];
   }
}
?>

any help would be much appreciated
may i add that the error only seems to happen on pages that ae loaded through the SSI.php script
for example this page
http://usaulnaynatation.site90.com/new/home.php

sp4rd0se

Hello


yes i take up and old topic but i need help how i can please the menu so it looks like this


Advertisement: