function smarty_template_function_categories_tree($_smarty_tpl, $params)
            {
                $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                foreach ($_smarty_tpl->smarty->template_functions['categories_tree']['parameter'] as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                foreach ($params as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                ?>
 <?php 
                if ($_smarty_tpl->tpl_vars['categories']->value) {
                    ?>
                            <ul>
        <?php 
                    $_smarty_tpl->tpl_vars['c1'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['c1']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['categories']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['c1']->key => $_smarty_tpl->tpl_vars['c1']->value) {
                        $_smarty_tpl->tpl_vars['c1']->_loop = true;
                        ?>
 <?php 
                        if ($_smarty_tpl->tpl_vars['c1']->value->visible) {
                            ?>
                                <li id="m<?php 
                            echo $_smarty_tpl->tpl_vars['c1']->value->id;
                            ?>
">
                                <a <?php 
                            if ($_smarty_tpl->tpl_vars['category']->value->id == $_smarty_tpl->tpl_vars['c1']->value->id) {
                                ?>
class="selected"<?php 
                            }
                            ?>
" href="<?php 
                            ob_start();
                            echo $_smarty_tpl->tpl_vars['c1']->value->id;
                            $_tmp1 = ob_get_clean();
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0][0]->url_modifier(array('keyword' => null, 'brand_id' => null, 'page' => null, 'category_id' => $_tmp1), $_smarty_tpl);
                            ?>
">
                                <?php 
                            if ($_smarty_tpl->tpl_vars['category']->value->id == $_smarty_tpl->tpl_vars['c1']->value->id) {
                                ?>
<i class="fa fa-angle-right"></i><?php 
                            }
                            ?>
                                <?php 
                            echo $_smarty_tpl->tpl_vars['c1']->value->name;
                            ?>
</a>
                                <?php 
                            if (in_array($_smarty_tpl->tpl_vars['category']->value->id, $_smarty_tpl->tpl_vars['c1']->value->children)) {
                                ?>
                                <?php 
                                smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->tpl_vars['c1']->value->subcategories));
                                ?>
 <?php 
                            }
                            ?>
</li>
                                <?php 
                        }
                        ?>
 <?php 
                    }
                    ?>
</ul><?php 
                }
                ?>
 <?php 
                $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                foreach (Smarty::$global_tpl_vars as $key => $value) {
                    if (!isset($_smarty_tpl->tpl_vars[$key])) {
                        $_smarty_tpl->tpl_vars[$key] = $value;
                    }
                }
            }
            function smarty_template_function_categories_tree($_smarty_tpl, $params)
            {
                $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                foreach ($_smarty_tpl->smarty->template_functions['categories_tree']['parameter'] as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                foreach ($params as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                ?>
	<?php 
                if ($_smarty_tpl->tpl_vars['categories']->value) {
                    ?>
	<ul>
		<?php 
                    if ($_smarty_tpl->tpl_vars['categories']->value[0]->parent_id == 0) {
                        ?>
		<li <?php 
                        if (!$_smarty_tpl->tpl_vars['category']->value->id) {
                            ?>
class="selected"<?php 
                        }
                        ?>
><a href="<?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0][0]->url_modifier(array('category_id' => null), $_smarty_tpl);
                        ?>
">Все категории</a></li>
		<?php 
                    }
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars['c'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['c']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['categories']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['c']->key => $_smarty_tpl->tpl_vars['c']->value) {
                        $_smarty_tpl->tpl_vars['c']->_loop = true;
                        ?>
		<li <?php 
                        if ($_smarty_tpl->tpl_vars['category']->value->id == $_smarty_tpl->tpl_vars['c']->value->id) {
                            ?>
class="selected"<?php 
                        }
                        ?>
><a href="index.php?module=FeaturesAdmin&category_id=<?php 
                        echo $_smarty_tpl->tpl_vars['c']->value->id;
                        ?>
"><?php 
                        echo $_smarty_tpl->tpl_vars['c']->value->name;
                        ?>
</a></li>
		<?php 
                        smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->tpl_vars['c']->value->subcategories));
                        ?>

		<?php 
                    }
                    ?>
	</ul>
	<?php 
                }
                ?>
	<?php 
                $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                foreach (Smarty::$global_tpl_vars as $key => $value) {
                    if (!isset($_smarty_tpl->tpl_vars[$key])) {
                        $_smarty_tpl->tpl_vars[$key] = $value;
                    }
                }
            }
                function smarty_template_function_categories_tree($_smarty_tpl, $params)
                {
                    $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                    foreach ($_smarty_tpl->smarty->template_functions['categories_tree']['parameter'] as $key => $value) {
                        $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                    }
                    foreach ($params as $key => $value) {
                        $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                    }
                    ?>
		<?php 
                    if ($_smarty_tpl->tpl_vars['categories']->value) {
                        ?>
		<div id="list" class="sortable">

			<?php 
                        $_smarty_tpl->tpl_vars['category'] = new Smarty_Variable();
                        $_smarty_tpl->tpl_vars['category']->_loop = false;
                        $_from = $_smarty_tpl->tpl_vars['categories']->value;
                        if (!is_array($_from) && !is_object($_from)) {
                            settype($_from, 'array');
                        }
                        foreach ($_from as $_smarty_tpl->tpl_vars['category']->key => $_smarty_tpl->tpl_vars['category']->value) {
                            $_smarty_tpl->tpl_vars['category']->_loop = true;
                            ?>
			<div class="<?php 
                            if (!$_smarty_tpl->tpl_vars['category']->value->visible) {
                                ?>
invisible<?php 
                            }
                            ?>
 row">
				<div class="tree_row">
					<input type="hidden" name="positions[<?php 
                            echo $_smarty_tpl->tpl_vars['category']->value->id;
                            ?>
]" value="<?php 
                            echo $_smarty_tpl->tpl_vars['category']->value->position;
                            ?>
">
					<div class="move cell" style="margin-left:<?php 
                            echo $_smarty_tpl->tpl_vars['level']->value * 20;
                            ?>
px"><div class="move_zone"></div></div>
			 		<div class="checkbox cell">
						<input type="checkbox" name="check[]" value="<?php 
                            echo $_smarty_tpl->tpl_vars['category']->value->id;
                            ?>
" />
					</div>
					<div class="cell">
						<a href="<?php 
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0][0]->url_modifier(array('module' => 'CategoryAdmin', 'id' => $_smarty_tpl->tpl_vars['category']->value->id, 'return' => $_SERVER['REQUEST_URI']), $_smarty_tpl);
                            ?>
"><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['category']->value->name, ENT_QUOTES, 'UTF-8', true);
                            ?>
</a>
					</div>
					<div class="icons cell">
						<a class="preview" title="Предпросмотр в новом окне" href="../catalog/<?php 
                            echo $_smarty_tpl->tpl_vars['category']->value->url;
                            ?>
" target="_blank"></a>
						<a class="enable" title="Активна" href="#"></a>
						<a class="delete" title="Удалить" href="#"></a>
					</div>
					<div class="clear"></div>
				</div>
				<?php 
                            smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->tpl_vars['category']->value->subcategories, 'level' => $_smarty_tpl->tpl_vars['level']->value + 1));
                            ?>

			</div>
			<?php 
                        }
                        ?>

		</div>
		<?php 
                    }
                    ?>
		<?php 
                    $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                    foreach (Smarty::$global_tpl_vars as $key => $value) {
                        if (!isset($_smarty_tpl->tpl_vars[$key])) {
                            $_smarty_tpl->tpl_vars[$key] = $value;
                        }
                    }
                }
            function smarty_template_function_categories_tree($_smarty_tpl, $params)
            {
                $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                foreach ($_smarty_tpl->smarty->template_functions['categories_tree']['parameter'] as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                foreach ($params as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                ?>
			<?php 
                if ($_smarty_tpl->tpl_vars['categories']->value) {
                    ?>
			<ul>
			<?php 
                    $_smarty_tpl->tpl_vars['c'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['c']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['categories']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['c']->key => $_smarty_tpl->tpl_vars['c']->value) {
                        $_smarty_tpl->tpl_vars['c']->_loop = true;
                        ?>
				
				<?php 
                        if ($_smarty_tpl->tpl_vars['c']->value->visible) {
                            ?>
					<li>
						<?php 
                            if ($_smarty_tpl->tpl_vars['c']->value->image) {
                                ?>
<img src="<?php 
                                echo $_smarty_tpl->tpl_vars['config']->value->categories_images_dir;
                                echo $_smarty_tpl->tpl_vars['c']->value->image;
                                ?>
" alt="<?php 
                                echo htmlspecialchars($_smarty_tpl->tpl_vars['c']->value->name, ENT_QUOTES, 'UTF-8', true);
                                ?>
"><?php 
                            }
                            ?>
						<a <?php 
                            if ($_smarty_tpl->tpl_vars['category']->value->id == $_smarty_tpl->tpl_vars['c']->value->id) {
                                ?>
class="selected"<?php 
                            }
                            ?>
 href="catalog/<?php 
                            echo $_smarty_tpl->tpl_vars['c']->value->url;
                            ?>
" data-category="<?php 
                            echo $_smarty_tpl->tpl_vars['c']->value->id;
                            ?>
"><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['c']->value->name, ENT_QUOTES, 'UTF-8', true);
                            ?>
</a>
						<?php 
                            smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->tpl_vars['c']->value->subcategories));
                            ?>

					</li>
				<?php 
                        }
                        ?>
			<?php 
                    }
                    ?>
			</ul>
			<?php 
                }
                ?>
			<?php 
                $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                foreach (Smarty::$global_tpl_vars as $key => $value) {
                    if (!isset($_smarty_tpl->tpl_vars[$key])) {
                        $_smarty_tpl->tpl_vars[$key] = $value;
                    }
                }
            }
            function smarty_template_function_categories_tree($_smarty_tpl, $params)
            {
                $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                foreach ($_smarty_tpl->smarty->template_functions['categories_tree']['parameter'] as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                foreach ($params as $key => $value) {
                    $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                }
                ?>
			<?php 
                if ($_smarty_tpl->tpl_vars['categories']->value) {
                    ?>
			<ul <?php 
                    if (in_array($_smarty_tpl->tpl_vars['category']->value->id, $_smarty_tpl->tpl_vars['c']->value->children)) {
                        ?>
class="cssmenu_left_level_<?php 
                        echo $_smarty_tpl->tpl_vars['c']->value->level + 1;
                        ?>
"<?php 
                    } else {
                        ?>
class="<?php 
                        if ($_smarty_tpl->tpl_vars['c']->value->level) {
                            ?>
cssmenu_left_level<?php 
                            echo $_smarty_tpl->tpl_vars['c']->value->level;
                        } else {
                            ?>
cssmenu_left<?php 
                        }
                        ?>
"<?php 
                    }
                    ?>
>
			<?php 
                    $_smarty_tpl->tpl_vars['c'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['c']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['categories']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['c']->key => $_smarty_tpl->tpl_vars['c']->value) {
                        $_smarty_tpl->tpl_vars['c']->_loop = true;
                        ?>
				
				<?php 
                        if ($_smarty_tpl->tpl_vars['c']->value->visible) {
                            ?>
					<li>
						
						
						<?php 
                            if ($_smarty_tpl->tpl_vars['c']->value->subcategories) {
                                ?>
						<a <?php 
                                if ($_smarty_tpl->tpl_vars['category']->value->id == $_smarty_tpl->tpl_vars['c']->value->id) {
                                    ?>
class="selected"<?php 
                                }
                                ?>
 href="catalog/<?php 
                                echo $_smarty_tpl->tpl_vars['c']->value->url;
                                ?>
" data-category="<?php 
                                echo $_smarty_tpl->tpl_vars['c']->value->id;
                                ?>
">► <?php 
                                echo htmlspecialchars($_smarty_tpl->tpl_vars['c']->value->name, ENT_QUOTES, 'UTF-8', true);
                                ?>
 (<?php 
                                echo $_smarty_tpl->tpl_vars['c']->value->count;
                                ?>
)</a>
						<?php 
                            } else {
                                ?>
						
						<?php 
                            }
                            ?>
											<?php 
                            if (in_array($_smarty_tpl->tpl_vars['category']->value->id, $_smarty_tpl->tpl_vars['c']->value->children)) {
                                ?>
						<?php 
                                smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->tpl_vars['c']->value->subcategories));
                                ?>

						<?php 
                            }
                            ?>
					</li>

				<?php 
                        }
                        ?>
			<?php 
                    }
                    ?>
			</ul>
			<?php 
                }
                ?>
			<?php 
                $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                foreach (Smarty::$global_tpl_vars as $key => $value) {
                    if (!isset($_smarty_tpl->tpl_vars[$key])) {
                        $_smarty_tpl->tpl_vars[$key] = $value;
                    }
                }
            }
    function smarty_template_function_categories_tree($_smarty_tpl, $params)
    {
        $saved_tpl_vars = $_smarty_tpl->tpl_vars;
        foreach ($_smarty_tpl->template_functions['categories_tree']['parameter'] as $key => $value) {
            $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
        }
        foreach ($params as $key => $value) {
            $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
        }
        ?>
	<?php 
        if ($_smarty_tpl->getVariable('categories')->value) {
            ?>
	<ul>
		<?php 
            if ($_smarty_tpl->getVariable('categories')->value[0]->parent_id == 0) {
                ?>
		<li <?php 
                if (!$_smarty_tpl->getVariable('category')->value->id) {
                    ?>
class="selected"<?php 
                }
                ?>
><a href="<?php 
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0][0]->url_modifier(array('category_id' => null, 'brand_id' => null), $_smarty_tpl);
                ?>
">Все категории</a></li>	
		<?php 
            }
            ?>
		<?php 
            $_smarty_tpl->tpl_vars['c'] = new Smarty_Variable();
            $_from = $_smarty_tpl->getVariable('categories')->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            if ($_smarty_tpl->_count($_from) > 0) {
                foreach ($_from as $_smarty_tpl->tpl_vars['c']->key => $_smarty_tpl->tpl_vars['c']->value) {
                    ?>
		<li category_id="<?php 
                    echo $_smarty_tpl->getVariable('c')->value->id;
                    ?>
" <?php 
                    if ($_smarty_tpl->getVariable('category')->value->id == $_smarty_tpl->getVariable('c')->value->id) {
                        ?>
class="selected"<?php 
                    } else {
                        ?>
class="droppable category"<?php 
                    }
                    ?>
><a href='<?php 
                    ob_start();
                    echo $_smarty_tpl->getVariable('c')->value->id;
                    $_tmp1 = ob_get_clean();
                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0][0]->url_modifier(array('keyword' => null, 'brand_id' => null, 'page' => null, 'category_id' => $_tmp1), $_smarty_tpl);
                    ?>
'><?php 
                    echo $_smarty_tpl->getVariable('c')->value->name;
                    ?>
</a></li>
		<?php 
                    smarty_template_function_categories_tree($_smarty_tpl, array('categories' => $_smarty_tpl->getVariable('c')->value->subcategories));
                    ?>

		<?php 
                }
            }
            ?>
	</ul>
	<?php 
        }
        $_smarty_tpl->tpl_vars = $saved_tpl_vars;
    }