fbpx

Astroid 2.4 Landed with Joomla 4 Compatibility Download Now

Welcome, Guest
Username: Password: Remember me

TOPIC: Main Menu - Multilanguage

Main Menu - Multilanguage 1 year 5 months ago #14098

Hi everyone, this is my first post here and first of alla would like to advise that my english isn't so good, so sorry me in advance.

I'm just setting a multilanguage website using astroid framework (after lot of years without using joomla), and would like to find an alternative way instead of to duplicate template.
As ozwest wrote and as you know, main menù will appear only in main language and not in others, because it's part of astroid header and not a separate module, so I solved this by creating a duplicate of template.
Bbut in this way there is a possibility to "forgot" to make same changes as original ones, so if you find a different solution will be happy to try it.

PS: I'm sure that astroid has lot of potentials that I will not use!
Last Edit: 1 year 5 months ago by angelocabodi.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14100

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 2
  • Karma: 1
Hello Angelocabodi

I have used a lot of different templates and frameworks over the time and I would like to say that I am so very pleased with the Astroid framework. I am sure there will be a solution very near down the track to utilise just one template with multiple languages . It is like you say it, changes to the template could be forgotten in the other languages etc. it is very tedious.

So I am hoping to understand and test what Chetan has suggested above and if I am successful I will post it here.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14108

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4145
  • Thank you received: 607
  • Karma: 108
Do Let me know how it goes, Or I can provide you with a code sample (working one) too if required.

Thanks,
Chetan
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14110

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 2
  • Karma: 1
That would be really awesome, Chetan. Thank you.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14143

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4145
  • Thank you received: 607
  • Karma: 108
Hello,

If you are using the horizontal.php menu layout, please see the following file: gist.github.com/chetanmadaan/3f75614603ccd4b0dad3631fe258b226

See instructions below:
The following code should be added in the header layout file, i.e. horizontal.php, sidebar.php, stacked.php and sticky.php (i.e. if you are using sticky menu you will have to make changes sticky.php and the layout file you are using).
Find the following line in your header layout file.
$header_menu = $params->get('header_menu', 'mainmenu');

Add the following code just before the line.
// Let's get the active ItemId.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
//
$menus = array(
// Language #1
	array(
	'menuname' => 'english-menu',
	'itemids' => array('1','2','3')
	),
// Language #2
	array(
	'menuname' => 'french-menu',
	'itemids' => array('4','5','6')
	),
// Language #3
	array(
	'menuname' => 'punjabi-menu',
	'itemids' => array('7','8','9')
	)
);
foreach($menus as $values) {
	if(in_array($itemId,$values['itemids'])){
		$header_menu = $values['menuname'];
	}
}

The code is pretty clear but still explaining what it does.
Above, I have listed 3 different menu names and associated menu items.
i.e. English Menu will be displayed on ItemId 1,2 and 3.
French menu will be displayed on ItemId 4,5 & 6.
Punjai menu will be displayed on ItemId 7,8 & 9.

You must change the menu names to match yours, you must also change the menu itemd's to match yours.
You don't have to keep 3 languages, you can just keep one or add 5 more.
If no itemId's match, the default menu select in the config will be displayed.

Hope this helps.
Cheers,
Chetan
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
Last Edit: 1 year 5 months ago by admin.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14166

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 2
  • Karma: 1
Hello Chetan

I have implemented your code in the website https://alliswellinallofcreation.com.

Lets clarify first:
- I am assuming you refer to the "menu typ" as menuname?
- I am assuming you refer to the "menu items ids" ad itemids?

The English menu (menuname . menu-english) displays no matter what I define as itemids. This is the menu I reference in the Astroid Header template as the menu to use.

The German menu does not display no matter if I reference the correct itemids or not.

However, if I am clicking on the language flag to change the language from English to German on any menu item, I do get the associated file in the other language.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14174

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4145
  • Thank you received: 607
  • Karma: 108
Can you share your code of the file (i.e. modified code), so I can see what your code looks like.

Yes, menu type is menu-name and menu item ids are ItemId's.

Thanks,
Chetan
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14202

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 2
  • Karma: 1
I am using the horizontal.php

<?php
/**
* @package Astroid Framework
* @author JoomDev www.joomdev.com
* @copyright Copyright (C) 2009 - 2019 JoomDev.
* @license www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
* DO NOT MODIFY THIS FILE DIRECTLY AS IT WILL BE OVERWRITTEN IN THE NEXT UPDATE
* You can easily override all files under /frontend/ folder.
* Just copy the file to ROOT/templates/YOURTEMPLATE/html/frontend/header/ folder to create and override
*/
// No direct access.
defined('_JEXEC') or die;

jimport('astroid.framework.menu');

extract($displayData);

$params = $template->params;
$mode = $params->get('header_horizontal_menu_mode', 'left');
$block_1_type = $params->get('header_block_1_type', 'blank');
$block_1_position = $params->get('header_block_1_position', '');
$block_1_custom = $params->get('header_block_1_custom', '');
$header_menu = $params->get('header_menu', 'mainmenu');
$enable_offcanvas = $params->get('enable_offcanvas', FALSE);
$header_mobile_menu = $params->get('header_mobile_menu', '');
$offcanvas_animation = $params->get('offcanvas_animation', 'st-effect-1');
$offcanvas_togglevisibility = $params->get('offcanvas_togglevisibility', 'd-block');
$class = ;
$navClass = ;
$navWrapperClass = ;
?>
<!-- header starts -->
<header data-megamenu data-megamenu-class=".has-megamenu" data-megamenu-content-class=".megamenu-container" data-dropdown-arrow="<?php echo $template->params->get('dropdown_arrow', 0) ? 'true' : 'false'; ?>" data-header-offset="true" data-transition-speed="<?php echo $template->params->get('dropdown_animation_speed', 300); ?>" data-animation="<?php echo $template->params->get('dropdown_animation_type', 'fade'); ?>" data-easing="<?php echo $template->params->get('dropdown_animation_ease', 'linear'); ?>" data-trigger="<?php echo $template->params->get('dropdown_trigger', 'hover'); ?>" data-megamenu-submenu-class=".nav-submenu,.nav-submenu-static" id="astroid-header" class="<?php echo implode(' ', $class); ?>">
<div class="d-flex flex-row justify-content-between">
<?php if (!empty($header_mobile_menu)) { ?>
<div class="d-flex d-lg-none justify-content-start">
<div class="header-mobilemenu-trigger d-lg-none burger-menu-button align-self-center" data-offcanvas="#astroid-mobilemenu" data-effect="mobilemenu-slide">
<button class="button" type="button"><span class="box"><span class="inner"></span></span></button>
</div>
</div>
<?php } ?>
<div class="header-left-section d-flex justify-content-between">
<?php $template->loadLayout('logo'); ?>
<?php
if ($mode == 'left') {
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
}
?>
</div>
<?php
if ($mode == 'center') {
echo '<div class="header-center-section d-flex justify-content-center">';
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
echo '</div>';
}
?>
<?php if ($block_1_type != 'blank' || $mode == 'right' || $enable_offcanvas): ?>
<div class="header-right-section d-flex justify-content-end">
<?php
if ($mode == 'right') {
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
}
?>
<?php if ($enable_offcanvas) { ?>
<div class="header-offcanvas-trigger burger-menu-button align-self-center <?php echo $offcanvas_togglevisibility; ?>" data-offcanvas="#astroid-offcanvas" data-effect="<?php echo $offcanvas_animation; ?>">
<button type="button" class="button">
<span class="box">
<span class="inner"></span>
</span>
</button>
</div>
<?php } ?>
<?php if ($block_1_type != 'blank'): ?>
<div class="header-right-block d-none d-lg-block align-self-center px-2">
<?php
if ($block_1_type == 'position') {
echo '<div class="header-block-item">';
echo $template->renderModulePosition($block_1_position, 'xhtml');
echo '</div>';
}
if ($block_1_type == 'custom') {
echo '<div class="header-block-item">';
echo $block_1_custom;
echo '</div>';
}
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</header>
<!-- header ends -->
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14203

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4145
  • Thank you received: 607
  • Karma: 108
It doesn't look like the code I provided was added. Please use the following horizontal.php gist.github.com/chetanmadaan/3f75614603ccd4b0dad3631fe258b226

Thanks,
Chetan
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Main Menu - Multilanguage 1 year 5 months ago #14206

  • ozwest
  • ozwest's Avatar
  • Offline
  • Premium Member
  • Posts: 89
  • Thank you received: 2
  • Karma: 1
Oh, of course, here it is ...

<?php
/**
* @package Astroid Framework
* @author JoomDev www.joomdev.com
* @copyright Copyright (C) 2009 - 2019 JoomDev.
* @license www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
* DO NOT MODIFY THIS FILE DIRECTLY AS IT WILL BE OVERWRITTEN IN THE NEXT UPDATE
* You can easily override all files under /frontend/ folder.
* Just copy the file to ROOT/templates/YOURTEMPLATE/html/frontend/header/ folder to create and override
*/
// No direct access.
defined('_JEXEC') or die;
jimport('astroid.framework.menu');
extract($displayData);
$params = $template->params;
$mode = $params->get('header_horizontal_menu_mode', 'left');
$block_1_type = $params->get('header_block_1_type', 'blank');
$block_1_position = $params->get('header_block_1_position', '');
$block_1_custom = $params->get('header_block_1_custom', '');

// Let's get the active ItemId.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
//
$menus = array(
// Language #1
array(
'menuname' => 'menu-english',
'itemids' => array('101','688','463','410','392','451','452','467','454','499','386','497','562','583','584')
),
// Language #2
array(
'menuname' => 'menu-german',
'itemids' => array('383','711','462','400','393','411','413','461','453','498','385','496','563','581','582')
)
);
foreach($menus as $values) {
if(in_array($itemId,$values)){
$header_menu = $values;
}
}


$header_menu = $params->get('header_menu', 'mainmenu');
// Let's get the active ItemId.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
//
$menus = array(
// Language #1
array(
'menuname' => 'footer-menu',
'itemids' => array('225','408','507')
),
// Language #2
array(
'menuname' => 'hidden-menu',
'itemids' => array('226','16','17')
),
// Language #3
array(
'menuname' => 'usermenu',
'itemids' => array('391','16','17')
)
);
foreach($menus as $values) {
if(in_array($itemId,$values)){
$header_menu = $values;
}
}
$enable_offcanvas = $params->get('enable_offcanvas', FALSE);
$header_mobile_menu = $params->get('header_mobile_menu', '');
$offcanvas_animation = $params->get('offcanvas_animation', 'st-effect-1');
$offcanvas_togglevisibility = $params->get('offcanvas_togglevisibility', 'd-block');
$class = ;
$navClass = ;
$navWrapperClass = ;
?>
<!-- header starts -->
<header data-megamenu data-megamenu-class=".has-megamenu" data-megamenu-content-class=".megamenu-container" data-dropdown-arrow="<?php echo $template->params->get('dropdown_arrow', 0) ? 'true' : 'false'; ?>" data-header-offset="true" data-transition-speed="<?php echo $template->params->get('dropdown_animation_speed', 300); ?>" data-animation="<?php echo $template->params->get('dropdown_animation_type', 'fade'); ?>" data-easing="<?php echo $template->params->get('dropdown_animation_ease', 'linear'); ?>" data-trigger="<?php echo $template->params->get('dropdown_trigger', 'hover'); ?>" data-megamenu-submenu-class=".nav-submenu,.nav-submenu-static" id="astroid-header" class="<?php echo implode(' ', $class); ?>">
<div class="d-flex flex-row justify-content-between">
<?php if (!empty($header_mobile_menu)) { ?>
<div class="d-flex d-lg-none justify-content-start">
<div class="header-mobilemenu-trigger d-lg-none burger-menu-button align-self-center" data-offcanvas="#astroid-mobilemenu" data-effect="mobilemenu-slide">
<button class="button" type="button"><span class="box"><span class="inner"></span></span></button>
</div>
</div>
<?php } ?>
<div class="header-left-section d-flex justify-content-between">
<?php $template->loadLayout('logo'); ?>
<?php
if ($mode == 'left') {
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
}
?>
</div>
<?php
if ($mode == 'center') {
echo '<div class="header-center-section d-flex justify-content-center">';
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
echo '</div>';
}
?>
<?php if ($block_1_type != 'blank' || $mode == 'right' || $enable_offcanvas): ?>
<div class="header-right-section d-flex justify-content-end">
<?php
if ($mode == 'right') {
// header nav starts
AstroidMenu::getMenu($header_menu, $navClass, null, 'left', 'horizontal', $navWrapperClass);
// header nav ends
}
?>
<?php if ($enable_offcanvas) { ?>
<div class="header-offcanvas-trigger burger-menu-button align-self-center <?php echo $offcanvas_togglevisibility; ?>" data-offcanvas="#astroid-offcanvas" data-effect="<?php echo $offcanvas_animation; ?>">
<button type="button" class="button">
<span class="box">
<span class="inner"></span>
</span>
</button>
</div>
<?php } ?>
<?php if ($block_1_type != 'blank'): ?>
<div class="header-right-block d-none d-lg-block align-self-center px-2">
<?php
if ($block_1_type == 'position') {
echo '<div class="header-block-item">';
echo $template->renderModulePosition($block_1_position, 'xhtml');
echo '</div>';
}
if ($block_1_type == 'custom') {
echo '<div class="header-block-item">';
echo $block_1_custom;
echo '</div>';
}
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</header>
<!-- header ends -->
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.434 seconds
Cron Job Starts