miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

First 10 words of message in the Recent Topics list

 
 
Page  Page 2 of 4:  « Previous  1  2  3  4  Next »

Author realitybytes
Partaker
#16 | Posted: 31 May 2006 00:12 
under

$lptxt=($textLd==1?$pVals[$topic][3]:strip_tags($pVals[$topic][3]));

in bb_func_ldisc.php file.

add

$words = count(explode(" ", $lptxt));
if($words > 10) {$exlptxt = explode(" ", $lptxt);
$lptxt = $exlptxt[0]." ".$exlptxt[1]." ".$exlptxt[2]." ".$exlptxt[3]." ".$exlptxt[4]." ".$exlptxt[5]." ".$exlptxt[6]." ".$exlptxt[7]." ".$exlptxt[8]." ".$exlptxt[9]; //10 words
$varlength = strlen($lptxt);
if($varlength > $textLdLnth){$lptxt = substr($lptxt, 0, $textLdLnth) . "...";}
else {$lptxt .= "...";}
}


You have a character variable which you can change which you will idealy need to test as you dont want anybody defacing your board from a post. I tested it on 70 it cut short some of the posts could always increase it up to yourself

can place this variable in setup options

$textLdLnth = 70;

varlength store the count of the characters

I think that is it.

Only tested it quickly might need tweaking slightly but it seemed ok.

Author tom322
Active Member
#17 | Posted: 31 May 2006 00:22 
Thanks! I think it works good - only one thing.. How to get rid of the formatting (so that $lptxt returns text without line breaks etc). Because now when someone wrote:

Hello,

Testing one two three, www.test.com etc.

the {$lptxt} returns:

Hello,

Testing one two three, www.test.com etc.


and it should return:

Hello, Testing one two three, www.test.com etc.

[without making the url active if possible].

tom

Author realitybytes
Partaker
#18 | Posted: 31 May 2006 00:26 
$textLd=2;

add that to setup options

Author tom322
Active Member
#19 | Posted: 31 May 2006 00:31 
realitybytes
This is perfect and it works I think! Thank you!!

tom

Author tom322
Active Member
#20 | Posted: 31 May 2006 00:33 
Now - If I knew how to get the first 10 words of the FIRST message, I would be thrilled..:)

tom

Author realitybytes
Partaker
#21 | Posted: 31 May 2006 00:34 
tom322
if you sort by new posts it is, but if you sort by New Topics it should be use the first post text.

if you want to show it even in case of New Posts sort type in the bb_func_ldisc.php try changing:

if($row=db_simpleSelect(0, $Tp, 'poster_id, poster_name, post_time, topic_id'.$textLdSql, '', '', '', 'post_id DESC'))

to:

if($row=db_simpleSelect(0, $Tp, 'poster_id, poster_name, post_time, topic_id'.$textLdSql, '', '', '', 'post_id ASC'))

Author tom322
Active Member
#22 | Posted: 31 May 2006 00:41 
Well, I changed it - but I'm not sure how to get the first 10 words of the first post then to put in the templates...

By first post I mean the very first post created by the user who posted a new topic, not the last reply. These first words would act like a description of the topic...

Also, I sort by new replies by default so shall I use {$lptxt} to get the first 10 words of the first post then? I would like to show the same 10 words even if there was a reply posted to this topic.

Author realitybytes
Partaker
#23 | Posted: 31 May 2006 00:51 
havent tested but looking at the file changing decs to acs on the sql statement looks like it should work

Author tom322
Active Member
#24 | Posted: 31 May 2006 00:57 
I think I confused you what I mean by the first words of the first post - I explained it above... i found some explanations here...: https://www.minibb.com/forums/5_3752_0.html

... but since the solution for the last post is done, maybe it's easy to do that too:)

Maybe to change this:

for ($post_id=first post in this topic) do


$words = count(explode(" ", $lptxt));
if($words > 10) {$exlptxt = explode(" ", $lptxt);
$lptxt = $exlptxt[0]." ".$exlptxt[1]." ".$exlptxt[2]." ".$exlptxt[3]." ".$exlptxt[4]." ".$exlptxt[5]." ".$exlptxt[6]." ".$exlptxt[7]." ".$exlptxt[8]." ".$exlptxt[9]; //10 words
$varlength = strlen($lptxt);
if($varlength > $textLdLnth){$lptxt = substr($lptxt, 0, $textLdLnth) . "...";}
else {$lptxt .= "...";}
}

or even better - to add a new variable to show the first post of the topic creator...

Author realitybytes
Partaker
#25 | Posted: 31 May 2006 01:24 
Yes that is what I thought you was getting at,

so reversing the order of the post id should return the first if it is defaulting to last from the sql statement.

Anyways I am out for the night might look in to it tomorrow if I get some spare time, unless somebody else coems up with a solution.

There is nothing in that statement we just created that will return the first post the variable is propegated from the sql statement. So that is where you need to look, which Paul highlighted can't say for sure now what needs changing needs some testing, if reversing the selection order is not working

Author tom322
Active Member
#26 | Posted: 31 May 2006 01:32 
OK, thank you for your great help. I think this is not so important but a nice feature for some of us:).

tom

Author tom322
Active Member
#27 | Posted: 31 May 2006 04:37 
I noticed one of the miniBB members has done it at http://www.html-site.nl/ - I want one too..:).

// I found a command that could be useful to do that at http://www.bernzilla.com/item.php?id=400 -- but it selects characters, not words... :|

Author realitybytes
Partaker
#28 | Posted: 31 May 2006 23:50 
Yes the Left function is built in to sql, and as it says there will select x number of characters.

I doubt I will have time to look in to it right now. What you need to avoid doing is changing the core too much, or at least that is a mind set I think of else you will run in to all kinds of problems leter on for upgrades and bug fixes.

So that puts it in a bracket of a plugin.

With the latest discussion there is no obvious trigger however you could create a seperate file and have a 1 line include in bb_func_ldisc.php

Which would not be too distructive. There are many variables that you can use to get the information you need already defined then just a case of matching selecting and storing retrieving the information from the database to the latest discussion cell.

Author Paul
Lead Developer 
#29 | Posted: 9 Jun 2006 08:37 
I think methods described are still code-destructive.

We can use parseTopic() function for getting our what Tom322 requests. This function must be created in bb_plugins.php file. If it's already created (it can be used for big amount of deals), paste in it only code necessary:

function parseTopic(){

/* Get first 10 words from post text - set $textLd=2; in setup before */
$lptxt=$GLOBALS['lastPostText'];
$sp=explode(' ', $lptxt);
if(sizeof($sp)>10) { $newTxt=''; for($i=0;$i<11;$i++) $newTxt.=$sp[$i].' '; $newTxt=trim($newTxt).'...'; }
else $newTxt=$lptxt;
$GLOBALS['lastPostTextShort']='<br /><span class="txtSm">'.$newTxt.'</span>';
/* --end of 10 words from post text code */

}
after that, you can use {$lastPostTextShort} variable in templates/main_last_discuss_cell.html or templates/main_topics_cell.html.

Try that and report the results...

Author Marius
Partaker
#30 | Posted: 1 Feb 2007 03:43 
Sorry for bringing this topic back to life...Great solution Paul, works beautifully. Just one request.

It elimates the br tag great, but doesn't insert a space character. So in other words, it glues the last word, and the first word on the new line, together making it one big word. This causes incorrect grammer and throws of word count.

How do I make sure it doesn't do that. I hope you can assist in this. Otherwise it is perfect.

Kind regards,

Marius

Page  Page 2 of 4:  « Previous  1  2  3  4  Next » 
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 First 10 words of message in the Recent Topics list
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑