AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Closed] Add snippet of first post into forum list

17 Posts
3 Users
5 Reactions
4,403 Views
Sofy
Posts: 5774
 Sofy
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 years ago

Hi @anonymous3542,

I'll ask developers and let you know asap. 


Posts: 392
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@anonymous3542)
Honorable Member
Joined: 9 years ago

@sofy thanks very much.


2 Replies
Sofy
 Sofy
Admin
(@sofy)
Joined: 8 years ago

Support Team
Posts: 5774
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@anonymous3542,

As far as I understand you'd like to mix the wpForo first Extended layout with the Threaded layouts, am I right? 

As you may see the wpForo Threaded layout includes only the titles. 

So what content you'll need to add here? Would you like to add some content from the first post or something else? 


(@anonymous3542)
Joined: 9 years ago

Honorable Member
Posts: 392
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@sofy that's correct. I'm just looking for the body of the first post in each topic to be displayed underneath


Sofy
Posts: 5774
 Sofy
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 years ago

Hi @anonymous3542,

I've asked deveolpers and the best way to do it I'll describe below. 

You should customize the forum-thread.php file in the wp-content/plugins/wpforo/wpf-themes/classic/layouts/4/ folder.

Add the following code in the file.  The code will show the body of the first post. I've attached the image below, please check it. On the screenshot, you'll see the row you should add the code.

<div class="custom-wpf-thread-first-post-body">
<?php
$topic = wpforo_topic($topicid);
$first_post_body = wpforo_post($topic['first_postid'], 'body');
wpforo_text($first_post_body, 250);
?>
</div>

As I've mentioned the code will just show the body of the first post. You'll need to add some CSS code, to display as it should be.

correct place

3 Replies
(@anonymous3542)
Joined: 9 years ago

Honorable Member
Posts: 392
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@sofy thanks very much for this. I've revamped this slightly to give it a more "native" feel - personally, I think this should be in the core, but that's just me

 <div class="custom-wpf-thread-first-post-body">
<?php

$topic = wpforo_topic($topicid);
$first_post_body = wpforo_post($topic['first_postid'], 'body');
// strip tags to avoid breaking any html
$string = strip_tags($first_post_body);
if (strlen($string) > 500) {

// truncate string
$stringCut = substr($string, 0, 500);
$endPoint = strrpos($stringCut, ' ');

//if the string doesn't contain any space then it will cut without word basis.
$string = $endPoint? substr($stringCut, 0, $endPoint) : substr($stringCut, 0);
$theurl = esc_url($thread['url']);
$string .= '...... <a href="' . $theurl . '"><span class="green"><b>Read More</b></span></a>';
}
echo "<div class='excerpt'>" . $string . "</div>";
?>
</div>

The CSS is simple enough - the excerpt doesn't show if in mobile view for obvious reasons

 


Sofy
 Sofy
Admin
(@sofy)
Joined: 8 years ago

Support Team
Posts: 5774
Sofy
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

Hi @anonymous3542,

I think this should be in the core, but that's just me

We'll discuss with our team to add this in plugin core. 


Robert
Admin
(@robert)
Joined: 3 months ago

Support Team
Posts: 10741
Sofy
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@anonymous3542,

I'm sorry but this is out of the threaded layout idea. You're asking change the threaded layout to extended layout. The result will be close to the extended layout. So this can only be done individually, I'm sorry but we'll not add it in core.


Page 2 / 2
Share: