Динамическая подгрузка элементов
Код в ТДС
// При аякс загрузке подменяем макет на пустой
if(Core_Array::getGet('ajax'))
{
Core_Page::instance()->template(
Core_Entity::factory('Template', 30) // пустой макет
);
if(Core_Array::getGet('ajax') == 'items')
{
$Informationsystem_Controller_Show
->addEntity(
Core::factory('Core_Xml_Entity')->name('ajax')->value(1)
);
}
}
Код в XSL шаблоне
<xsl:template match="/informationsystem">
<xsl:choose>
<xsl:when test="ajax = 1">
<!-- Выводим только элементы -->
<xsl:apply-templates select="informationsystem_item[active=1]"/>
</xsl:when>
<xsl:otherwise>
<!-- Стандартный вывод -->
<!-- ... -->
<div class="portfolio-thumbs articles" data-page="{/informationsystem/page + 1}" data-pages="{ceiling(total div limit)}" id="portfolio">
<xsl:apply-templates select="informationsystem_item[active=1]"/>
</div>
<!-- ... -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Код на странице
$(".more_posts a").live('click', function(e){
container = "#portfolio";
page = parseInt($(container).attr('data-page')); // текущая страница
pages = parseInt($(container).attr('data-pages')); // общее число страниц
if(page >= pages)
{
return false;
}
e.preventDefault();
$.loadingScreen('show');
jQuery.ajax({
type: 'GET',
url: 'page-' + (page + 1) + '/',
data: 'ajax=items',
success: function(content){
$(container).append(content);
$(container).attr('data-page', ++page);
if(page >= pages)
{
// скрываем кнопку показать еще
$(".more_posts").css("display", "none");
}
$.loadingScreen('hide');
}
});
});