×
Kunena 5.1.15 Released (27 Oct 2019)

The Kunena team has announce the arrival of Kunena 5.1.15 [K 5.1.15] which is now available for download as a native Joomla extension for J! 3.9.x. This version addresses most of the issues that were discovered in K 5.1 and issues discovered during the development stages of K 5.1.

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

More
9 months 4 weeks 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
9 months 4 weeks ago - 9 months 4 weeks 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: 9 months 4 weeks 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.089 seconds