Отображение групп и подгрупп магазина
Для отображения на главной странице всех групп и подгрупп каталога магазина делаю так:
В макете вывожу
В xml
Все работает, но не могу грамотно оформить.
Хочу все это дело оформить в таблице все в 1 блок <td>, но не получается потому, что два шаблона
.
Так вот какой вопрос созрел:
Возможно ли объединить два шаблона (xsl:template), то есть в пихнуть содержимое шаблона подгрупп в шаблон групп и если возможно то как это реализовать, что бы объединить в таблице в один <td> все содержимое
В макете вывожу
if (Core::moduleIsActive('shop'))
{
$Shop_Controller_Show = new Shop_Controller_Show(
Core_Entity::factory('Shop', 1)
);
$Shop_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('МагазинКаталогТоваров')
)
->itemsProperties('true')
->groupsMode('all')
->show();
}
{
$Shop_Controller_Show = new Shop_Controller_Show(
Core_Entity::factory('Shop', 1)
);
$Shop_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('МагазинКаталогТоваров')
)
->itemsProperties('true')
->groupsMode('all')
->show();
}
В xml
<xsl:template match="shop_group">
<tr>
<xsl:for-each select=". | following-sibling::shop_group[position() < $n]">
<td>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
<xsl:if test="count(shop_group) > 0">
<tr>
<xsl:apply-templates select="shop_group" mode="sub_group"/>
</tr>
</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="shop_group" mode="sub_group">
<td>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
</td>
</xsl:template>
<tr>
<xsl:for-each select=". | following-sibling::shop_group[position() < $n]">
<td>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
<xsl:if test="count(shop_group) > 0">
<tr>
<xsl:apply-templates select="shop_group" mode="sub_group"/>
</tr>
</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="shop_group" mode="sub_group">
<td>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
</td>
</xsl:template>
Все работает, но не могу грамотно оформить.
Хочу все это дело оформить в таблице все в 1 блок <td>, но не получается потому, что два шаблона
.Так вот какой вопрос созрел:
Возможно ли объединить два шаблона (xsl:template), то есть в пихнуть содержимое шаблона подгрупп в шаблон групп и если возможно то как это реализовать, что бы объединить в таблице в один <td> все содержимое
Сейчас выводится так:
А нужно так:
<h1>Каталог товаров</h1>
<div class="group_list">
<div id="item-top-area">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="50%" align="justify">
<div class="item-top-img"><a href="/shop/sukhie-stroitelnye-smesi/" target="_blank"><img src="/upload/shop_1/5/9/4/group_594/small_shop_group_image594.jpg" align="middle" /></a> </div>
<div class="item-top-text"><span class="item-top-section-name"><a href="/shop/sukhie-stroitelnye-smesi/">Сухие строительные смеси </a></span>>
<span class="shop_count">2</span></div>
<tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/sukhie-tsementnye-smesi/">Сухие цементные смеси.</a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/klei-plitochnyi/">Клей плиточный.</a> </div>
</td>
</tr>
</td>
<td width="50%" align="justify">
<div class="item-top-img"><a href="/shop/gipsokarton-tssp-sml/" target="_blank"><img src="/upload/shop_1/5/9/2/group_592/small_shop_group_image592.jpg" align="middle" /></a> </div>
<div class="item-top-text"><span class="item-top-section-name"><a href="/shop/gipsokarton-tssp-sml/">Гипсокартон. ЦСП. СМЛ</a></span>>
<span class="shop_count">7</span></div>
<tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gkl/">ГКЛ</a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gklv/">ГКЛВ</a> </div>
</td>
</tr>
</td>
</tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/">Сухие строительные смеси </a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/">Гипсокартон. ЦСП. СМЛ</a> </div>
</td>
</tbody>
</table>
</div>
</div>
<div class="group_list">
<div id="item-top-area">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="50%" align="justify">
<div class="item-top-img"><a href="/shop/sukhie-stroitelnye-smesi/" target="_blank"><img src="/upload/shop_1/5/9/4/group_594/small_shop_group_image594.jpg" align="middle" /></a> </div>
<div class="item-top-text"><span class="item-top-section-name"><a href="/shop/sukhie-stroitelnye-smesi/">Сухие строительные смеси </a></span>>
<span class="shop_count">2</span></div>
<tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/sukhie-tsementnye-smesi/">Сухие цементные смеси.</a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/klei-plitochnyi/">Клей плиточный.</a> </div>
</td>
</tr>
</td>
<td width="50%" align="justify">
<div class="item-top-img"><a href="/shop/gipsokarton-tssp-sml/" target="_blank"><img src="/upload/shop_1/5/9/2/group_592/small_shop_group_image592.jpg" align="middle" /></a> </div>
<div class="item-top-text"><span class="item-top-section-name"><a href="/shop/gipsokarton-tssp-sml/">Гипсокартон. ЦСП. СМЛ</a></span>>
<span class="shop_count">7</span></div>
<tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gkl/">ГКЛ</a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gklv/">ГКЛВ</a> </div>
</td>
</tr>
</td>
</tr>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/">Сухие строительные смеси </a> </div>
</td>
<td>
<div class="item-top-text"><a class="level_2_link" href="/shop/gipsokarton-tssp-sml/">Гипсокартон. ЦСП. СМЛ</a> </div>
</td>
</tbody>
</table>
</div>
</div>
А нужно так:
<h1>Каталог товаров</h1>
<div class="group_list">
<div id="item-top-area">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50%" align="justify">
<div class="item-top-img">
<a href="/shop/sukhie-stroitelnye-smesi/" title="Сухие строительные смеси">
<img src="/upload/shop_1/5/9/4/group_594/small_shop_group_image594.jpg" align="middle" alt="Сухие строительные смеси" />
</a>
</div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="/shop/sukhie-stroitelnye-smesi/" title="">
Сухие строительные смеси </a>
</span>
<span class="shop_count">2</span></div><br/>
<a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/sukhie-tsementnye-smesi/">Сухие цементные смеси.</a>
<a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/klei-plitochnyi/">Клей плиточный.</a>
</div>
</td>
<td width="50%" align="justify">
<div class="item-top-img">
<a href="/shop/gipsokarton-tssp-sml/" title="Гипсокартон. ЦСП. СМЛ">
<img src="/upload/shop_1/5/9/2/group_592/small_shop_group_image592.jpg" align="middle" />
</a>
</div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="/shop/gipsokarton-tssp-sml/" title="">
Гипсокартон. ЦСП. СМЛ </a>
</span>
<span class="shop_count">26</span><br/>
<a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gkl/">ГКЛ</a>
<a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gklv/">ГКЛВ</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="group_list">
<div id="item-top-area">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50%" align="justify">
<div class="item-top-img">
<a href="/shop/sukhie-stroitelnye-smesi/" title="Сухие строительные смеси">
<img src="/upload/shop_1/5/9/4/group_594/small_shop_group_image594.jpg" align="middle" alt="Сухие строительные смеси" />
</a>
</div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="/shop/sukhie-stroitelnye-smesi/" title="">
Сухие строительные смеси </a>
</span>
<span class="shop_count">2</span></div><br/>
<a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/sukhie-tsementnye-smesi/">Сухие цементные смеси.</a>
<a class="level_2_link" href="/shop/sukhie-stroitelnye-smesi/klei-plitochnyi/">Клей плиточный.</a>
</div>
</td>
<td width="50%" align="justify">
<div class="item-top-img">
<a href="/shop/gipsokarton-tssp-sml/" title="Гипсокартон. ЦСП. СМЛ">
<img src="/upload/shop_1/5/9/2/group_592/small_shop_group_image592.jpg" align="middle" />
</a>
</div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="/shop/gipsokarton-tssp-sml/" title="">
Гипсокартон. ЦСП. СМЛ </a>
</span>
<span class="shop_count">26</span><br/>
<a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gkl/">ГКЛ</a>
<a class="level_2_link" href="/shop/gipsokarton-tssp-sml/gklv/">ГКЛВ</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Всех с новым годом!
Вопрос снимаю
разобрался сам 
Сделал так: (может кому...)
Вопрос снимаю
разобрался сам 
Сделал так: (может кому...)
<!-- Шаблон для групп товара -->
<xsl:template match="shop_group">
<tr>
<xsl:for-each select=". | following-sibling::shop_group[position() < $n]">
<td width="50%" align="justify">
<div style="margin: 25px;">
<div class="item-top-img">
<xsl:if test="image_small!=''">
<a href="{url}" target="_blank">
<img src="{dir}{image_small}" align="middle"/>
</a><xsl:text> </xsl:text></xsl:if></div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</span>>
<xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
</div>
<xsl:if test="count(shop_group) > 0">
<xsl:apply-templates select="shop_group" mode="sub_group"/>
</xsl:if>
</div>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="shop_group" mode="sub_group">
<a class="level_2_link" href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="shop_group">
<tr>
<xsl:for-each select=". | following-sibling::shop_group[position() < $n]">
<td width="50%" align="justify">
<div style="margin: 25px;">
<div class="item-top-img">
<xsl:if test="image_small!=''">
<a href="{url}" target="_blank">
<img src="{dir}{image_small}" align="middle"/>
</a><xsl:text> </xsl:text></xsl:if></div>
<div class="item-top-text">
<span class="item-top-section-name">
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</span>>
<xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
</div>
<xsl:if test="count(shop_group) > 0">
<xsl:apply-templates select="shop_group" mode="sub_group"/>
</xsl:if>
</div>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template match="shop_group" mode="sub_group">
<a class="level_2_link" href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select="name"/></a><xsl:text> </xsl:text>
</xsl:template>
Авторизация