Вопрос по выводу информационных систем, с разбиением на дни
Звиняйте, ежели пишу не в ту ветку.
Имеется сайт на главной нужно вывести содержимое 4х инфосистем за последние 7 дней. Сайт увидите, станет понятнее. Как это можно реализовать? Поискал на форуме, документацию еще не всю пропарсил. Подскажите, если уже где-то есть ответ, подозреваю, что это не так сложно. Или любую информацию, которая поможет приблизиться к решению.
код шалона для главной:
<div class="date-note">
<div class="date-heading">
<div class="wrapper">
<div class="data">ВТОРНИК, 31 ДЕКАБРЯ [<span class="fulldate">31/12/2013</span>]</div>
<div class="hide">
<a href="#" onclick="$('.spoiler1').slideToggle('slow'); return false;">скрыть<span><img src="images/ardown.png"></span></a>
</div>
</div>
</div>
<div class="list-wrapper">
<div class="spoiler1">
<div class="opinions">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$jj=Core_Entity::factory('Xsl')->getByName('Мнения');
$jj->queryBuilder()
->where('value', '=', 186);
$aBooks = $jj->findAll();
print_r($aBooks);
$Informationsystem_Controller_Show
->xsl(
$jj
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3);
}
$Informationsystem_Controller_Show->show();
?>
</div>
<div class="media">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '20')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Медиагвоздь')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="analytics">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '21')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Аналитика')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="news">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '22')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Новости')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="clr"></div>
</div>
</div>
</div>
<div class="date-note">
<div class="date-heading">
<div class="wrapper">
<div class="data">ВТОРНИК, 31 ДЕКАБРЯ [<span class="fulldate">31/12/2013</span>]</div>
<div class="hide">
<a href="#" onclick="$('.spoiler2').slideToggle('slow'); return false;">скрыть<span><img src="images/ardown.png"></span></a>
</div>
</div>
</div>
<div class="list-wrapper">
<div class="spoiler2">
<div class="opinions">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Мнения')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="media">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '20')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Медиагвоздь')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="analytics">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '21')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Аналитика')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="news">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '22')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Новости')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="clr"></div>
</div>
</div>
</div>
xsl-шаблон одного из блоков:
Все вот так вот, пока по-нубски
Извиняюсь за простыни кода, так, на всякий. Суть итак понятна.
Ну и на главной сейчас выводятся две даты, т.к. просто в шаблоне для главной код отображения инфосистемы продублирован.
p.s. нашел вот это но пока код адаптировать под свою задачу не получается.
p.s. таблица property_value_datetimes у меня пустая совершенно.
Имеется сайт на главной нужно вывести содержимое 4х инфосистем за последние 7 дней. Сайт увидите, станет понятнее. Как это можно реализовать? Поискал на форуме, документацию еще не всю пропарсил. Подскажите, если уже где-то есть ответ, подозреваю, что это не так сложно. Или любую информацию, которая поможет приблизиться к решению.
код шалона для главной:
<div class="date-note">
<div class="date-heading">
<div class="wrapper">
<div class="data">ВТОРНИК, 31 ДЕКАБРЯ [<span class="fulldate">31/12/2013</span>]</div>
<div class="hide">
<a href="#" onclick="$('.spoiler1').slideToggle('slow'); return false;">скрыть<span><img src="images/ardown.png"></span></a>
</div>
</div>
</div>
<div class="list-wrapper">
<div class="spoiler1">
<div class="opinions">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$jj=Core_Entity::factory('Xsl')->getByName('Мнения');
$jj->queryBuilder()
->where('value', '=', 186);
$aBooks = $jj->findAll();
print_r($aBooks);
$Informationsystem_Controller_Show
->xsl(
$jj
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3);
}
$Informationsystem_Controller_Show->show();
?>
</div>
<div class="media">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '20')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Медиагвоздь')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="analytics">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '21')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Аналитика')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="news">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '22')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Новости')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="clr"></div>
</div>
</div>
</div>
<div class="date-note">
<div class="date-heading">
<div class="wrapper">
<div class="data">ВТОРНИК, 31 ДЕКАБРЯ [<span class="fulldate">31/12/2013</span>]</div>
<div class="hide">
<a href="#" onclick="$('.spoiler2').slideToggle('slow'); return false;">скрыть<span><img src="images/ardown.png"></span></a>
</div>
</div>
</div>
<div class="list-wrapper">
<div class="spoiler2">
<div class="opinions">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Мнения')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="media">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '20')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Медиагвоздь')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
</div>
<div class="analytics">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '21')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Аналитика')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="news">
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '22')
);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Новости')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(4)
->show();
}?>
</div>
<div class="clr"></div>
</div>
</div>
</div>
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:template match="/">
<xsl:apply-templates select="/informationsystem"/>
</xsl:template>
<xsl:template match="/informationsystem">
<h2 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</h2>
<div class="little-line"></div>
<xsl:apply-templates select="informationsystem_item"/>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="informationsystem_item">
<xsl:if test="description != ''">
<xsl:choose>
<xsl:when test="property_value[tag_name='video']/value = '1'">
<div class="video-pre">
<a href="{url}" class="nb-heading" hostcms:id="{@id}"
hostcms:field="name" hostcms:entity="informationsystem_item">
<xsl:if test="image_small != ''">
<!-- Проверяем задан ли путь к файлу изображения -->
<img src="{dir}{image_small}" />
</xsl:if>
</a>
<h3>
<a href="{url}" class="nb-heading" hostcms:id="{@id}"
hostcms:field="name" hostcms:entity="informationsystem_item">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</h3>
</div>
</xsl:when>
<xsl:otherwise>
<div class="twitter-container">
<xsl:value-of disable-output-escaping="yes" select="description"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<!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:template match="/">
<xsl:apply-templates select="/informationsystem"/>
</xsl:template>
<xsl:template match="/informationsystem">
<h2 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</h2>
<div class="little-line"></div>
<xsl:apply-templates select="informationsystem_item"/>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="informationsystem_item">
<xsl:if test="description != ''">
<xsl:choose>
<xsl:when test="property_value[tag_name='video']/value = '1'">
<div class="video-pre">
<a href="{url}" class="nb-heading" hostcms:id="{@id}"
hostcms:field="name" hostcms:entity="informationsystem_item">
<xsl:if test="image_small != ''">
<!-- Проверяем задан ли путь к файлу изображения -->
<img src="{dir}{image_small}" />
</xsl:if>
</a>
<h3>
<a href="{url}" class="nb-heading" hostcms:id="{@id}"
hostcms:field="name" hostcms:entity="informationsystem_item">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</h3>
</div>
</xsl:when>
<xsl:otherwise>
<div class="twitter-container">
<xsl:value-of disable-output-escaping="yes" select="description"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Все вот так вот, пока по-нубски

Извиняюсь за простыни кода, так, на всякий. Суть итак понятна.
Ну и на главной сейчас выводятся две даты, т.к. просто в шаблоне для главной код отображения инфосистемы продублирован.
p.s. нашел вот это но пока код адаптировать под свою задачу не получается.
p.s. таблица property_value_datetimes у меня пустая совершенно.
Таки нашел решение самостоятельно:
(может кому пригодится когда-нибудь)
В шаблоне вызываем вывод содержимого информационной системы:
собственно все. (Ну и еще завернуть в цикл 7ми-дневный от сегодня назад по дням)
Нашел нужный кусок кода в файле:
/modules/informationsystem/item/model.php
Не знал, что можно прямо в вызове отображения добавить в запрос нужные параметры.
И еще вот здесь оказывается описано про это
(может кому пригодится когда-нибудь)
В шаблоне вызываем вывод содержимого информационной системы:
<?php
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$Informationsystem_Controller_Show
->informationsystemItems()
->queryBuilder()
//->where('datetime', '=', '2013-12-30 17:29:40');
->having(Core_Querybuilder::expression("DATETIME
BETWEEN '2013-12-30 00:00:00'
AND '2013-12-31 00:00:00'"), '=', 1);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Мнения')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
if (Core::moduleIsActive('informationsystem'))
{
$Informationsystem_Controller_Show = new Informationsystem_Controller_Show(
Core_Entity::factory('Informationsystem', '19')
);
$Informationsystem_Controller_Show
->informationsystemItems()
->queryBuilder()
//->where('datetime', '=', '2013-12-30 17:29:40');
->having(Core_Querybuilder::expression("DATETIME
BETWEEN '2013-12-30 00:00:00'
AND '2013-12-31 00:00:00'"), '=', 1);
$Informationsystem_Controller_Show
->xsl(
Core_Entity::factory('Xsl')->getByName('Мнения')
)
->groupsMode('none')
->itemsForbiddenTags(array('text'))
->itemsProperties(TRUE)
->group(FALSE)
->limit(3)
->show();
}?>
собственно все. (Ну и еще завернуть в цикл 7ми-дневный от сегодня назад по дням)
Нашел нужный кусок кода в файле:
/modules/informationsystem/item/model.php
public function getByGroupId($group_id)
{
$this->queryBuilder()
//->clear()
->where('informationsystem_group_id', '=', $group_id)
->where('shortcut_id', '=', 0);
return $this->findAll();
}
{
$this->queryBuilder()
//->clear()
->where('informationsystem_group_id', '=', $group_id)
->where('shortcut_id', '=', 0);
return $this->findAll();
}
Не знал, что можно прямо в вызове отображения добавить в запрос нужные параметры.
И еще вот здесь оказывается описано про это
Авторизация