Добавить картинку к пункту меню

#
Добавить иконку FontAwesome к пункту меню
PHP код типовой динамической страницы такой:
<?php
$menu_id = Core_Array::get(Core_Page::instance()->widgetParams, 'menuId');
$linkedObject = Core_Entity::factory('Structure_Property_List', 'siteId');
$aProperties = $linkedObject->Properties->findAll();
$aProperty_Dirs = $linkedObject->Property_Dirs->findAll();
$xsl = Core_Array::get(Core_Page::instance()->widgetParams, 'xsl');
$Structure_Controller_Show = new Structure_Controller_Show(Core_Entity::factory('Site', CURRENT_SITE));
$Structure_Controller_Show
->xsl(Core_Entity::factory('Xsl')
->getByName($xsl))
->showShopGroups(true)
->menu($menu_id)
->showProperties(true)
->show();
?>
#
Добавить иконку FontAwesome к пункту меню
А XSL-шаблона такой:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml" />

<xsl:variable name="current_structure_id" select="/site/current_structure_id" />
<xsl:template match="/site">
<div class="navbar navbar-default navbar-toggleable float-right">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#topmenu"></button>
<div class="collapse navbar-collapse">
   
<ul class="nav navbar-nav">
<xsl:apply-templates select="*[@id][show=1][active=1]" />
</ul></div></div>
</xsl:template>

<xsl:template match="*"><li>
<xsl:if test="*[@id][show=1][active=1]"><xsl:attribute name="class">dropdown</xsl:attribute></xsl:if>
<xsl:if test="$current_structure_id = @id or count(.//structure[@id=$current_structure_id]) = 1">
<xsl:attribute name="class">dropdown current</xsl:attribute></xsl:if>
<xsl:variable name="link"><xsl:choose>
<xsl:when test="url != ''"><xsl:value-of disable-output-escaping="yes" select="url" /></xsl:when>
            <xsl:otherwise><xsl:value-of disable-output-escaping="yes" select="link" /></xsl:otherwise>
</xsl:choose></xsl:variable>

<xsl:value-of select="property_value[tag_name='file_description']/value" />
     <i class="fa fa-{property_value[tag_name='file_description']/value} fa-lg"></i>

<a href="{$link}" role="button" aria-haspopup="true" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="structure">
<xsl:if test="*[@id][show=1][active=1]">
<xsl:attribute name="data-toggle">dropdown</xsl:attribute>
<xsl:attribute name="class">dropdown-toggle</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
<xsl:if test="*[@id][show=1][active=1]"></xsl:if>
</a>

<xsl:if test="*[@id][show=1][active=1]">
   <ul class="dropdown-menu" id="menu1"><xsl:apply-templates select="*[@id][show=1][active=1]" mode="submenu" /></ul>
</xsl:if>
</li></xsl:template>

<xsl:template match="*" mode="submenu"><li>
<xsl:if test="*[@id][show=1][active=1]"><xsl:attribute name="class">dropdown</xsl:attribute></xsl:if>
<xsl:variable name="link"><xsl:choose>
<xsl:when test="url != ''"><xsl:value-of disable-output-escaping="yes" select="url" /></xsl:when>
<xsl:otherwise><xsl:value-of disable-output-escaping="yes" select="link" /></xsl:otherwise>
</xsl:choose></xsl:variable>
<a href="{$link}" role="button" aria-haspopup="true" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="structure">
<xsl:if test="*[@id][show=1][active=1]">
<xsl:attribute name="data-toggle">dropdown</xsl:attribute>
<xsl:attribute name="class">dropdown-toggle</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
<xsl:choose>
<xsl:when test="*[@id][show=1][active=1]"><i class="fa fa-angle-right"></i></xsl:when>
<xsl:otherwise></xsl:otherwise></xsl:choose></a>
<xsl:if test="*[@id][show=1][active=1]"><ul class="dropdown-menu sub-menu">
<xsl:apply-templates select="*[@id][show=1][active=1]" mode="sub-submenu" />
</ul></xsl:if>
</li></xsl:template>

<xsl:template match="*" mode="sub-submenu"><li>
<xsl:if test="*[@id][show=1][active=1]"><xsl:attribute name="class">dropdown</xsl:attribute></xsl:if>
<xsl:variable name="link"><xsl:choose>
<xsl:when test="url != ''"><xsl:value-of disable-output-escaping="yes" select="url" /></xsl:when>
<xsl:otherwise><xsl:value-of disable-output-escaping="yes" select="link" /></xsl:otherwise>
</xsl:choose></xsl:variable>
<a href="{$link}" role="button" aria-haspopup="true" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="structure"><xsl:value-of select="name" /></a>
</li></xsl:template>
</xsl:stylesheet>


Что делаю не так? Кто подскажет?
Нужна иконка FontAwesome в пункте меню.
#
Re: Добавить картинку к пункту меню
Да, в дополнительных свойствах узла структуры, например, вот так.
#
Добавить иконку FontAwesome к пункту меню
А надо чтобы выглядело примерно вот так:
Модератор
#
Re: Добавить картинку к пункту меню
Вывод свойств в XSL: https://www.hostcms.ru/documentation/modules/properties/xsl/
https://www.hostcms.ru/api6/class-Structure_Controller_Show.html
->showProperties(TRUE|FALSE) выводить значения дополнительных свойств усзлов структуры, по умолчанию FALSE
#
Добавить иконку FontAwesome к пункту меню
Спасибо.
Очень внимательно прочитал, но всё равно не пойму что я пишу не так:
<i class="fa fa-{property_value[tag_name='file_small_description']/value} fa-lg"></i>
#
Добавить иконку FontAwesome к пункту меню
Вот так делаю:
<i class="fa fa-cogs fa-lg"></i>
- всё выводится,
а через переменную не получается...
Модератор
#
Re: Добавить картинку к пункту меню
kamardindg,

У вас точно свойство называется file_small_description? Или все же у вас доп.свойства типа "Файл" и у него в описании малого изображения указываете значение?
Вы только что начали читать предложение, чтение которого вы уже заканчиваете.
Авторизация