Добрый день!
При включении PHP7 сайт ругается на код модуля, который создает выпадающее меню.
(function($) {
$(document).ready(function(){
$("#block-block-10 li div .active").parents(".item-list1 .item-list").parent().children("a").addClass('active').parent().children('div').show();
});
})(jQuery);
<?php
$term_parent = (object)array('tid'=>0);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if($node->type == 'product') {
$items = field_get_items('node', $node, 'field_product_category');
$term = (object)$items[0];
$term_parent = taxonomy_term_load($term->tid);
}
}
/**
* Return rendered taxonomy tree
*/
function mymodule_taxonomy_tree($vocabulary_name, $term_parent) {
$vid = taxonomy_vocabulary_machine_name_load($vocabulary_name)->vid;
$terms = taxonomy_get_tree($vid);
return theme('item_list', array('items' => _mymodule_taxonomy_tree($terms, 0, $term_parent)));
}
/**
* Helper for mymodule_taxonomy_tree()
*/
function _mymodule_taxonomy_tree($terms, $parent = 0, $term_parent) {
$items = array();
foreach ($terms as $term) {
if (in_array($parent, $term->parents)) {
if($term_parent->tid == $term->tid)
$items[] = array(
'data' => l('' . $term->name . '','taxonomy/term/' . $term->tid, array('html' => true, 'attributes'=>array('class'=>array('active')))),
'children' => _mymodule_taxonomy_tree($terms, $term->tid, $term_parent),
);
else
$items[] = array(
'data' => l('' . $term->name . '','taxonomy/term/' . $term->tid, array('html' => true)),
'children' => _mymodule_taxonomy_tree($terms, $term->tid, $term_parent),
);
}
}
return $items;
}
echo mymodule_taxonomy_tree('product_category', $term_parent);
?>
Подскажите что можно в нем подредактировать
Комментарии
Не надо создавать дубликаты тем.
В предыдущем посте я уже всё разъяснил. Этот код у вас находится в кастомном блоке с php фильтром. Ему там не место.
Jquery код перенесите в js файл темы оформления. Php код в препроцесс темы оформления.