Forums / Setup & design / Create a list of replies in forum

Create a list of replies in forum

Author Message

Ole Brudvik

Thursday 14 April 2005 5:41:08 am

Hi

Im trying to create a list of replies to a topic. Cant figure out how to do it.

I want the list to appear in the right colon:
http://singteach.nie.edu.sg/index.php/singteach/forum/teacher_work_attachment

This is my kode:

{let topic_list=fetch('content','list',hash( parent_node_id, $node.node_id,
                                             limit, 20,
                                             offset, $view_parameters.offset,
                                             sort_by, array( array( attribute, false(), 'forum_topic/sticky' ), array( 'modified_subnode', false() ) ) ) )
     topic_count=fetch('content','list_count',hash(parent_node_id,$node.node_id))}
<div class="categoryheading">Forum</div><p>
<div class="articleheading">
 

    {$node.name|wash}

</div>
<p>
    <div class="contentgreybig">
    {attribute_view_gui attribute=$node.object.data_map.description}
    </div>
</p>

    {section show=is_unset( $versionview_mode )}
    {section show=$node.object.can_create}
        <form method="post" action={"content/action/"|ezurl}>
            <input class="enter" type="submit" name="NewButton" value="{'New topic'|i18n( 'design/base' )}" />
            <input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
            <input type="hidden" name="ContentObjectID" value="{$node.contentobject_id.}" />
            <input class="enter" type="submit" name="ActionAddToNotification" value="{'Keep me updated'|i18n( 'design/base' )}" />
            <input type="hidden" name="NodeID" value="{$node.node_id}" />
            <input type="hidden" name="ClassIdentifier" value="forum_topic" />
        </form>
    {section-else}
        <p>  <div class="contentorangebold">
        {"You need to be logged in to participate in the forums. You can do so %login_link_start%here%login_link_end%"|i18n( "design/base",,
         hash( '%login_link_start%', concat( '<a href=', '/user/login/'|ezurl, '>' ), '%login_link_end%', '</a>' ) )}
       </div><br> </p>
    {/section}
    {/section}


    <div class="topics">

        <table class="listforum" align="center" cellspacing="0" border="1">
        <tr class="forumcell">
            <td width="35%" class="topics">
                {"Topic"|i18n( "design/base" )}
            </td>
            <td width="20%" class="topics">
                {"Total Replies"|i18n( "design/base" )}
            </td>
            <td width="22%" class="topics">
                {"Author"|i18n( "design/base" )}
            </td>
            <td width="22%" class="topics">
                {"Replies"|i18n( "design/base" )}
            </td>
        </tr>

        {section var=topic loop=$topic_list sequence=array( bglight, bgdark )}
        {let topic_reply_count=fetch( 'content', 'tree_count', hash( parent_node_id, $topic.node_id ) )
             topic_reply_pages=sum( int( div( sum( $topic_reply_count, 1 ), 20 ) ), cond( mod( sum( topic_reply_count, 1 ), 20 )|gt( 0 ), 1, 0 ) )}
        <tr class="tc">
            <td class="contentorange2">

                {$topic.object.name|wash}</p>
                {section show=$topic_reply_count|gt( sub( 20, 1 ) )}
                    <p>
                    {'Pages'|i18n( 'design/base' )}:
                    {section show=$topic_reply_pages|gt( 5 )}
                        <a href={$topic.url_alias|ezurl}>1</a>...
                        {section var=reply_page loop=$topic_reply_pages offset=sub( $topic_reply_pages, sub( 5, 1 ) )}
                            <a href={concat( $topic.url_alias, '/(offset)/', mul( sub( $reply_page, 1 ), 20 ) )|ezurl}>{$reply_page}</a>
                        {/section}
                    {section-else}
                        <a href={$topic.url_alias|ezurl}>1</a>
                        {section var=reply_page loop=$topic_reply_pages offset=1}
                            <a href={concat( $topic.url_alias, '/(offset)/', mul( sub( $reply_page, 1 ), 20 ) )|ezurl}>{$reply_page}</a>
                        {/section}
                    {/section}
                    </p>
                {/section}
            </td>
            <td class="replies">
                <p>{$topic_reply_count}</p>
            </td>
            <td class="author">
                <div class="attribute-byline">
                   <p class="date">{$topic.object.published|l10n(shortdatetime)}</p>
                   <p class="author">{$topic.object.owner.name|wash}</p>
                </div>
            </td>
            <td class="listforumalignleft">
            {let last_reply=fetch('content','list',hash( parent_node_id, $topic.node_id,
                                                         sort_by, array( array( 'published', false() ) ),
                                                         limit, 1 ) )}
                {section var=reply loop=$last_reply show=$last_reply}
                <div class="attribute-byline">
                   <p class="date">{$reply.object.published|l10n(shortdatetime)}</p>
                   <p class="author">{$reply.object.owner.name|wash}</p>
                </div>
                {section show=$topic_reply_count|gt( 19 )}
                    <p><a href={concat( $reply.parent.url_alias, '/(offset)/', sub( $topic_reply_count, mod( $topic_reply_count, 20 ) ) , '#msg', $reply.node_id )|ezurl}>{$reply.name|wash}</a></p>
                {section-else}
                    <p><a href={concat( $reply.parent.url_alias, '#msg', $reply.node_id )|ezurl}>{$reply.name|wash}</a></p>
                {/section}
                {/section}
           {/let}
           </td>
        </tr>
        {/let}
        {/section}
        </table>

    </div>

    </div>
</div>
{include name=navigator
         uri='design:navigator/google.tpl'
         page_uri=concat('/content/view','/full/',$node.node_id)
         item_count=$topic_count
         view_parameters=$view_parameters
         item_limit=20}

{/let}

Ɓukasz Serwatka

Friday 15 April 2005 1:49:15 am

See

http://ez.no/community/forum/setup_design/setting_up_forum_and_the_templates#msg73066

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

eZ debug

Timing: Jan 31 2025 06:29:46
Script start
Timing: Jan 31 2025 06:29:46
Module start 'content'
Timing: Jan 31 2025 06:29:46
Module end 'content'
Timing: Jan 31 2025 06:29:46
Script end

Main resources:

Total runtime0.0145 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1563180.8281
Module start 'content' 0.00560.0050 768.984498.0078
Module end 'content' 0.01070.0038 866.992274.7031
Script end 0.0144  941.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002214.9353120.0002
Check MTime0.00106.8750120.0001
Mysql Total
Database connection0.00085.469010.0008
Mysqli_queries0.002517.511840.0006
Looping result0.00000.090520.0000
Template Total0.003423.710.0034
Template load0.00095.890510.0009
Template processing0.002617.829510.0026
Override
Cache load0.00064.101010.0006
General
dbfile0.00032.3048100.0000
String conversion0.00000.042830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs