Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 4 Ответов
  • 3678 Просмотров
*

danik.html

  • Живу я здесь
  • 2650
  • 353 / 4
Плюсы данного решения:
- Работает на mootools и не тянет за собой jquery или ченибудь подобное.
- Не подключает внешних файлов скриптов - в мутулзе уже встроен класс Accordion.
- Не требует установки новых модулей - все делается на уровне шаблона
Минусы я заметил такие:
- Проблема когда на сайте два и более модуля меню (можно решить).
- Немаленький размер кода инициализации - 40 строк кода.

Как сделать:
Создаем пустой текствый файл default.php в templates/your_template/html/mod_mainmenu/ . Если такой папки нет - создайте ее.
Вставляем туда
[spoiler title=вот это вот]
Код: php
<?php

// no direct access
defined('_JEXEC') or die('Restricted access');


if ( ! defined('modMainMenuXMLCallbackDefined') )
{
function modMainMenuXMLCallback(&$node, $args)
{
$user = &JFactory::getUser();
$menu = &JSite::getMenu();
$active = $menu->getActive();
$path = isset($active)? array_reverse($active->tree) : null;

if (($args['end']) && ($node->attributes('level') >= $args['end']))
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}

if ($node->name() == 'ul') {
foreach ($node->children() as $child)
{
if ($child->attributes('access') > $user->get('aid', 0)) {
$node->removeChild($child);
}
}
}

if (($node->name() == 'li') && isset($node->ul)) {
$node->addAttribute('class', 'parent');
}

if (isset($path) && (in_array($node->attributes('id'), $path) || in_array($node->attributes('rel'), $path)))
{
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' active');
} else {
$node->addAttribute('class', 'active');
}
}
else
{
if (isset($args['children']) && !$args['children'])
{
$children = $node->children();
foreach ($node->children() as $child)
{
if ($child->name() == 'ul') {
$node->removeChild($child);
}
}
}
}

if (($node->name() == 'li') && ($id = $node->attributes('id'))) {
if ($node->attributes('class')) {
$node->addAttribute('class', $node->attributes('class').' item'.$id);
} else {
$node->addAttribute('class', 'item'.$id);
}
}

if (isset($path) && $node->attributes('id') == $path[0]) {
$node->addAttribute('id', 'current');
} else {
$node->removeAttribute('id');
}
$node->removeAttribute('rel');
$node->removeAttribute('level');
$node->removeAttribute('access');
}
define('modMainMenuXMLCallbackDefined', true);
}

$params->get('tag_id') or $params->set('accordion');


$script = "
window.addEvent('domready', function(){

$$($('{$params->get('tag_id')}'), $('{$params->get('tag_id')}').getElements('ul')).each(function(el){
accParentItems = el.getChildren().filterByClass('parent');
accTogglers = [];
accElements = [];
accParentItems.each(function(element, index){
accTogglers.push(new Element('span').injectTop(element));
accElements.push(element.getElementsByTagName('ul')[0]);
element.index = index;
element.addEvent('mouseover', function(){
if (this.getChildren().filterByTag('ul')[0].offsetHeight == 0) {
accTimer = this.parentNode.Accordion.display.delay(200, this.parentNode.Accordion, $(this).index);
}
});
element.addEvent('mouseout', function(){
if((accTimer != undefined)){clearTimeout(accTimer)};
});

});
if ( accParentItems.length > 0 ){
el.Accordion = new Accordion(accTogglers, accElements, {
opacity: false,
alwaysHide: true,
show: $$(accParentItems).indexOf($$(accParentItems).filterByClass('active')[0]),
duration: 200,
transition: Fx.Transitions.Quart.easeOut,
onActive: function(toggler, element){
element.parentNode.parentNode.setStyle('height', 'auto');
},
onBackground: function(toggler, element){
element.parentNode.parentNode.setStyle('height', 'auto');
element.setStyle('height', element.offsetHeight+'px');
}
}
);
}
});

});
";

// require mootools
JHTML::_('behavior.mootools');
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);

modMainMenuHelper::render($params, 'modMainMenuXMLCallback');

[/spoiler]

если ктонить шарит в js и mootools, помогите упростить код:
[spoiler title="accordion js"]
Код: javascript
window.addEvent('domready', function(){

$$($('{$params->get('tag_id')}'), $('{$params->get('tag_id')}').getElements('ul')).each(function(el){
accParentItems = el.getChildren().filterByClass('parent');
accTogglers = [];
accElements = [];
accParentItems.each(function(element, index){
accTogglers.push(new Element('span').injectTop(element));
accElements.push(element.getElementsByTagName('ul')[0]);
element.index = index;
element.addEvent('mouseover', function(){
if (this.getChildren().filterByTag('ul')[0].offsetHeight == 0) {
accTimer = this.parentNode.Accordion.display.delay(200, this.parentNode.Accordion, $(this).index);
}
});
element.addEvent('mouseout', function(){
if((accTimer != undefined)){clearTimeout(accTimer)};
});

});
if ( accParentItems.length > 0 ){
el.Accordion = new Accordion(accTogglers, accElements, {
opacity: false,
alwaysHide: true,
show: $$(accParentItems).indexOf($$(accParentItems).filterByClass('active')[0]),
duration: 200,
transition: Fx.Transitions.Quart.easeOut,
onActive: function(toggler, element){
element.parentNode.parentNode.setStyle('height', 'auto');
},
onBackground: function(toggler, element){
element.parentNode.parentNode.setStyle('height', 'auto');
element.setStyle('height', element.offsetHeight+'px');
}
}
);
}
});

});
[/spoiler]
« Последнее редактирование: 11.09.2010, 08:09:44 от danik.html »
【Мегапак Virtuemart:
 • метатеги (description,keywords)
 • заголовки (title)
 • красивые алиасы (чпу) без тормозов и дублей!
*

alko22

  • Новичок
  • 3
  • 0 / 0
Добрый вечер.А точно работает?у меня в стандартном меню работает как раздвижное меню,но! при клике на родительский элемент перегружается страница а это плохо.
Если работает более подробно обьясни пустой файл default.php создаем в mod_mainmenu ?там есть такой файл и дальше
"accordion js" это куда?Разьясните вот мой сайт глянте http://www.mir-turservis.com.ua/
*

danik.html

  • Живу я здесь
  • 2650
  • 353 / 4
при клике на родительский элемент перегружается страница
Естественно. Это ведь ссылка. При клике  - переходим по ссылке, что тут плохого то...
Делайте значет не ссылки, а разделители (такой тип пункта меню)
Если работает более подробно обьясни пустой файл default.php создаем в mod_mainmenu ?
Да, в первом посте же все написано.
"accordion js" это куда?
Это не для вас, это тоже написано.
【Мегапак Virtuemart:
 • метатеги (description,keywords)
 • заголовки (title)
 • красивые алиасы (чпу) без тормозов и дублей!
*

alko22

  • Новичок
  • 3
  • 0 / 0
если делаешь разделителем меню не раздвигается.
ставил sbd acordeonmenu там неполучается кнопки изображениями как в стандартном меню
*

Joker

  • Захожу иногда
  • 235
  • 3 / 0
ТС, можешь привести пример где реализовано меню?

сталкнулся с проблемой, надо вертикальное меню с иконками реализовать . не могу найти как реализовать
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

убрать из меню заголовки h3

Автор nexter

Ответов: 19
Просмотров: 6468
Последний ответ 03.02.2020, 18:49:47
от durte
При добавлении нового пункта меню не отображается содержимое

Автор Denko

Ответов: 2
Просмотров: 2146
Последний ответ 16.01.2020, 18:40:55
от Denko
Не нажимается пункт меню на мобильной версии

Автор Sensession

Ответов: 7
Просмотров: 3098
Последний ответ 04.01.2020, 16:45:27
от xpank
Не отображаются пункты в меню

Автор physic

Ответов: 20
Просмотров: 21395
Последний ответ 20.09.2019, 16:54:01
от beliyadm
Как в ARI Ext Menu добиться работы параметра "Показать в меню"?

Автор vasmed

Ответов: 1
Просмотров: 2359
Последний ответ 01.03.2019, 11:12:18
от vasmed