Задать вопрос
@Giperion63

Обратная сортировка по дате в вопросах блока FAQ — последние вопросы по дате сначала?

Здравствуйте.
Подскажите, как сделать обратную сортировку по дате при выводе вопросов-ответов раздела FAQ

За вывод отвечает данный раздел. Выводит сначала старые вопросы, а новые - на последних страницах.
Заранее спасибо.
Код раздела FAQ
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE local [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY laquo  "&#171;">
	<!ENTITY raquo  "&#187;">
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>

<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)&gt;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">&nbsp;</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>


  • Вопрос задан
  • 111 просмотров
Подписаться 1 Оценить Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы