×
Blue Eagle 5 v1.5.3 has been Released (31 Mar 2020)

The Kunena team has announce the arrival of Kunena template Blue Eagle 5 v1.5.3 which is now available for download. This version addresses most of the issues that were discovered in development.

Solved Solved: Show first post text in category view list of posts

More
1 year 2 months ago #1 by ianrispin
When viewing a category or latest posts or any list of posts...

I would like to show a snippet of the first post message text below the topic title.

This same snippet is already shown in the tooltip - I just think it would look nice if it is shown below the topic title as part of the row for that topic.

I cannot find a config option to do this.

So i am setting about modding the template.

I know I have to edit

my_template/layouts/topic/row/default.php

I know where to make the edit - just after:
<div class="started">
			<span class="ktopic-category"> <?php echo Text::sprintf('COM_KUNENA_CATEGORY_X', $this->getCategoryLink($this->topic->getCategory(), null, $this->topic->getCategory()->description, KunenaTemplate::getInstance()->tooltips())) ?></span>
			<br/>

But i cannot figure out what variable to display to show the message.

I have tried;
$message->displayField('message');

But it doesnt work i guess cos at that point in code the item being referenced is the topic not the message.

Can anyone help?

Please Log in or Create an account to join the conversation.

More
1 year 2 months ago - 1 year 2 months ago #2 by ianrispin
Just managed to get this working.

If anyone else is interested - here is the code you need to add to your template to show the first message text.
<?php $this->message = KunenaForumMessageHelper::get($this->topic->first_post_id);
echo $this->message->displayField('message'); ?>

Of course you then may wish to format to your preference.

I put it in this template: my_template/layouts/topic/row/default.php

It goes in the code like this:
<div class="started">
<span class="ktopic-category"> <?php echo Text::sprintf('COM_KUNENA_CATEGORY_X', $this->getCategoryLink($this->topic->getCategory(), null, $this->topic->getCategory()->description, KunenaTemplate::getInstance()->tooltips())) ?></span>
<br/>
 
<?php $this->message = KunenaForumMessageHelper::get($this->topic->first_post_id);
echo $this->message->displayField('message'); ?>
Last edit: 1 year 2 months ago by ianrispin.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.054 seconds