Answer the question
In order to leave comments, you need to log in
Reverse sort by date in FAQ block questions - latest questions by date first?
Hello.
Tell me how to do reverse sorting by date when displaying questions and answers in the FAQ
section This section is responsible for the output. Displays old questions first, and new ones on the last pages.
Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE local [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY laquo "«">
<!ENTITY raquo "»">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:udt="http://umi-cms.ru/2007/UData/templates"
xmlns:xlink="http://www.w3.org/TR/xlink"
extension-element-prefixes="php"
exclude-result-prefixes="xsl php date udt xlink">
<xsl:variable name="pagin-faq-results" select="document('udata://faq/category/notemplate/61')/udata" />
<!-- Вывод списка вопросов категории -->
<xsl:template match="result[@module='faq'][@method='project']" mode="module_content">
<xsl:apply-templates select="document('udata://faq/addQuestionForm/notemplate/61')" mode="question_form"/>
<xsl:apply-templates select="document('udata://faq/category/notemplate/61')/udata" />
<xsl:apply-templates select="document(concat('udata://system/numpages/', $pagin-faq-results/total, '/', $pagin-faq-results/per_page, '/notemplate/p/10'))" mode="pagination_faq" />
</xsl:template>
<!-- Вывод пейджинга -->
<xsl:template match="udata[not(tobegin_link) and toend_link]" mode="pagination_faq">
<div class="pagination">
<a class="previous">Предыдущая</a>
<xsl:apply-templates select="document(concat('udata://system/numpages/', $pagin-faq-results/total, '/', $pagin-faq-results/per_page, '/notemplate/p/5'))/udata/items/item" mode="pagination_faq_links"/>
<a class="next active" href="{tonext_link}">Следующая</a>
</div>
</xsl:template>
<xsl:template match="udata[tobegin_link and toend_link]" mode="pagination_faq">
<div class="pagination">
<a class="previous active" href="{toprev_link}">Предыдущая</a>
<xsl:apply-templates select="document(concat('udata://system/numpages/', $pagin-faq-results/total, '/', $pagin-faq-results/per_page, '/notemplate/p/5'))/udata/items/item" mode="pagination_faq_links"/>
<a class="next active" href="{tonext_link}">Следующая</a>
</div>
</xsl:template>
<xsl:template match="udata[tobegin_link and not(toend_link)]" mode="pagination_faq">
<div class="pagination">
<a class="previous active" href="{toprev_link}">Предыдущая</a>
<xsl:apply-templates select="document(concat('udata://system/numpages/', $pagin-faq-results/total, '/', $pagin-faq-results/per_page, '/notemplate/p/5'))/udata/items/item" mode="pagination_faq_links"/>
<a class="next">Следующая</a>
</div>
</xsl:template>
<xsl:template match="udata[items]" mode="pagination_faq_links">
<div class="paging-numbers">
<xsl:apply-templates select="items" mode="pagination_faq_links" />
</div>
</xsl:template>
<xsl:template match="item" mode="pagination_faq_links">
<a class="active" href="{@link}">
<xsl:value-of select="." />
</a>
</xsl:template>
<xsl:template match="item[@is-active = '1']" mode="pagination_faq_links">
<a class="unactive">
<xsl:value-of select="." />
</a>
</xsl:template>
<!-- Вывод одного вопроса -->
<xsl:template match="udata[@module='faq'][@method='category']">
<p>Нет сообщений</p>
</xsl:template>
<xsl:template match="udata[@module='faq'][@method='category'][count(items/item)>0]">
<xsl:apply-templates select="items/item" mode="faq_category">
<!--xsl:variable name="item-info" select="document(concat('upage://', @id))" />
<xsl:sort select="$item-info//property[@name = 'publish_time']/value/@unix-timestamp" order="descending"/-->
</xsl:apply-templates>
</xsl:template>
<xsl:template match="item" mode="faq_category">
<xsl:apply-templates select="document(concat('upage://',@id))" mode="faq_category_item" />
</xsl:template>
<xsl:template match="udata" mode="faq_category_item">
<xsl:variable name="author_id" select="//property[@name='author_id']/value/item/@id" />
<div class="question">
<span class="date">
<xsl:apply-templates select="//property[@name='publish_time']/value/@unix-timestamp" mode="costum_day_faq"/>
<span>
<xsl:apply-templates select="//property[@name='publish_time']/value/@unix-timestamp" mode="costum_month_faq"/>
</span>
</span>
<h4 class="big">
<span class="theme">Вопрос</span>
<span class="name"> </span>
</h4>
<p>
<xsl:value-of select="//property[@name='question']/value" />
</p>
</div>
<xsl:if test="//property[@name='answer']">
<div class="answer">
<h4 class="big_admin">Ответ</h4>
<p>
<xsl:value-of select="//property[@name='answer']/value" />
</p>
</div>
</xsl:if>
</xsl:template>
<!-- Вывод числа даты -->
<xsl:template match="@unix-timestamp" mode="costum_day_faq">
<xsl:value-of select="document(concat('udata://system/convertDate/',.,'/(d)'))/udata" />
</xsl:template>
<!-- Вывод месяца даты -->
<xsl:template match="@unix-timestamp" mode="costum_month_faq">
<xsl:value-of select="document(concat('udata://system/convertDate/',.,'/(F)'))/udata" />
</xsl:template>
<!--Сообщение об успешной отправке вопроса-->
<xsl:template match="result[@module='faq'][@method='post_question']" mode="module_content">
<div id="res">
<h1>Ваше сообщение успешно отправлено</h1>
<p>После проверки администратором оно появится на нашем сайте</p>
</div>
</xsl:template>
<!-- Вывод формы для добавления вопроса -->
<xsl:template match="udata[@module='faq'][@method='addQuestionForm']" mode="question_form">
<div>
<xsl:value-of select="document('udata://system/listErrorMessages')" />
</div>
<h4 class="form_header">Хотите что-нибудь у нас спросить?</h4>
<div class="form">
<form method="POST" data-action="{//action}" action="#" id="formQ">
<div>
<label>Меня зовут:
<span style="color:#ff0000">*</span>
</label>
<div>
<input type="text" name="nick"/>
</div>
</div>
<div>
<label>Мой e-mail:
<span style="color:#ff0000">*</span>
</label>
<div>
<input type="text" name="email" />
</div>
</div>
<input type="hidden" name="title" value="Вопрос"/>
<div class="textarea">
<label class="textarea">Хотелось бы узнать:
<span style="color:#ff0000">*</span>
</label>
<div>
<textarea name="question"></textarea>
</div>
<div class="clear"></div>
</div>
<!--div class="captcha">
<xsl:apply-templates select="document('udata://system/captcha')/udata[url]" />
</div-->
<div class="submit">
<input type="submit" value="спросить"/>
</div>
</form>
<div class="clear"></div>
</div>
</xsl:template>
<!--Тест Тьюринга-->
<xsl:template match="udata[@method='captcha']">
<label for="captcha" id="for_captcha" >Защитный код:</label>
<div>
<input type="text" name="captcha" id="captcha"/>
</div>
<img src="{url}{@random_string}" />
</xsl:template>
</xsl:stylesheet>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question