|
|
 |
October 11th, 2008, 12:22 PM
|
#1
|
|
Most Reputable Member
SuperMember
Join Date: Nov 2005
Location: webprocafe
Age: 28
Posts: 1,544
Thanks: 1
Thanked 11 Times in 11 Posts
Rep Altering Power: 0
|
latest blogs problem
I have a script to show my latest blogs on my homepage, but I want to firstly limit the amount of text ( and be able to display it in the area I have without stretching the area any wider ) and I want to stop images being included.. could anyone help ?
here is the code
Code:
require_once(DIR . '/includes/class_bbcode.php'); $parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
function truncate($text,$numb,$etc = "...") { $text = html_entity_decode($text, ENT_QUOTES); if (strlen($text) > $numb) { $text = substr($text, 0, $numb); $text = substr($text,0,strrpos($text," "));
$punctuation = ".!?:;,-"; //punctuation you want removed
$text = (strspn(strrev($text), $punctuation)!=0) ? substr($text, 0, -strspn(strrev($text), $punctuation)) : $text;
$text = $text.$etc; } return $text; }
$latestblogs = $db->query(" SELECT blog.blogid, blog.title, blog.username, blog.dateline, blog.userid, blog.views, blog.comments_visible, blog.lastcommenter, blog.lastblogtextid, blog_text.pagetext FROM " . TABLE_PREFIX . "blog INNER JOIN blog_text ON blog_text.blogtextid = blog.firstblogtextid WHERE blog.state = 'visible' ORDER BY blog.dateline DESC LIMIT 6 "); while ($showblogs=$db->fetch_array($latestblogs)) { $counter++; $blog_userid = $showblogs['userid']; $blogid = $showblogs['blogid']; $blog_title = $showblogs['title']; $blog_views = $showblogs['views']; $blog_username = $showblogs['username']; $blog_dateline = vbdate($vbulletin->options['dateformat'], $showblogs['dateline'],true); $blog_commentsvisible = $showblogs['comments_visible']; $blog_lastcommenter = $showblogs['lastcommenter']; $blog_lastblogtextid = $showblogs['lastblogtextid']; $blog_text = $showblogs['pagetext']; $blog_text = str_replace("[YOUTUBE]","",$blog_text); $blog_text = str_replace("[/YOUTUBE]","",$blog_text); $blog_text = str_replace("[youtube]","",$blog_text); $blog_text = str_replace("[/youtube]","",$blog_text); $blog_text = $parser->do_parse($blog_text, $vbulletin->options['eft_bbcode_html'], $vbulletin->options['eft_bbcode_smilies'], $vbulletin->options['eft_bbcode_bbcode'], $vbulletin->options['eft_bbcode_img'], 1, 0); $blog_text = truncate($blog_text,100);
$spitblogs_html .= "<tr><td class=\"alt1\">$blog_dateline</td></tr><tr><td class=\"alt2 bigfont\">"; $spitblogs_html .= "<strong><a class=\"bigfont\" href=\"blog.php?b=$blogid\">$blog_title</a></strong>"; $spitblogs_html .= "<div><em>$blog_text</em></div>"; $spitblogs_html .= "<div style=\"float:right; text-align:right;\">posted by <a href=\"member.php?u=$blog_userid\">$blog_username</a><br />{$blog_commentsvisible} comments"; if ($blog_commentsvisible > 0) { $spitblogs_html .= "<br />last comment: <a href=\"blog.php?b=$blogid#comment$blog_lastblogtextid\">$blog_lastcommenter</a>"; } $spitblogs_html .= "</div></td></tr>";
if ($counter < 5) { $spitblogs .= "<br /> "; } }
thank you... if you want to see where this goes, please go to my homepage ( link in signature )
thank you
p.s.. with the one currently on my homepage, I have just commented out the part that would show the post, that is why it only shows the title and a couple of bits of info
Last edited by saltedm8; October 11th, 2008 at 12:41 PM..
|
|
|
October 12th, 2008, 05:40 PM
|
#2
|
|
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
You can limit the amount of text that goes into each post by simply modifing the database field. Basically your post will have a 'title' i imagine, so simply allow only 120 characters for that field. Then i imagine each post has its own body, so allow up to 250 characters for that field. You can do this easily without writing any mysql code if your use Phpmyadmin.
As for your site streching when content over loads it, then i would advice using a CSS tableless div layout, becuase you can format the width & lengh so much easier. - Also it wont STRECH  ..
If you need any help with the Layout let me no and i will post a empty 3 coloum layout up for you to loo at...
Good Look. 
|
|
|
October 12th, 2008, 09:23 PM
|
#3
|
|
Most Reputable Member
SuperMember
Join Date: Nov 2005
Location: webprocafe
Age: 28
Posts: 1,544
Thanks: 1
Thanked 11 Times in 11 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
thanks for the help mate, but unfortunately, my php skills are very very limited... the reason for the tables is because that is what vbulletin happens to use ( check this forum ).. the reason why I was asking about the layout problem is because I don't know how to integrate the css with php ( my css skills are pretty good )
I did not write this script, it just happens to be part of a plugin that i use.. would you be able to give me examples of some of the stuff you explained please ( I can handle the css just not the integration )
Last edited by saltedm8; October 12th, 2008 at 09:26 PM..
|
|
|
October 13th, 2008, 05:37 AM
|
#4
|
|
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
Quote:
Originally Posted by saltedm8
thanks for the help mate, but unfortunately, my php skills are very very limited... the reason for the tables is because that is what vbulletin happens to use ( check this forum ).. the reason why I was asking about the layout problem is because I don't know how to integrate the css with php ( my css skills are pretty good )
I did not write this script, it just happens to be part of a plugin that i use.. would you be able to give me examples of some of the stuff you explained please ( I can handle the css just not the integration )
|
Hi mate how are you this morning?
I have created a small table that could hold posts using mysql code. Inside you will notice i have capped or truncated the 'header' to 150 characters. I have truncated the 'body' of the post to 250 characters. Therefore no one will be able to post the bible in one post if u understand me  ...
Code:
CREATE TABLE `posts` ( `id` int(11) NOT NULL auto_increment, `header` varchar(150) NOT NULL, `body` varchar(250) NOT NULL, `date` datetime NOT NULL, `usersid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
Hope this helps you 
|
|
|
October 13th, 2008, 05:41 AM
|
#5
|
|
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
Only me again check out this web page if you prefer to validate the input using php & not mysql... http://articles.techrepublic.com.com...1-6078577.html
|
|
|
October 13th, 2008, 06:16 AM
|
#6
|
Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
|
Re: latest blogs problem
Will substr() not work for you (for the number of characters you want to display,) Glynn? Have a look at the PHP Manual, also, using this method you wont need to muck up vBulletin's Database.
Last edited by Marc; October 13th, 2008 at 06:18 AM..
|
|
|
October 13th, 2008, 06:25 AM
|
#7
|
|
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
Like the guy said he does not no much PHP therefore i have showed him the simplest method of solving his problem. I dont see how restricting the amount of characters will muck up vBulletin's Database  .. any database can be easily modified this way and truncating the string will not require any of his script to be changed...
|
|
|
October 13th, 2008, 04:30 PM
|
#8
|
|
Most Reputable Member
Join Date: May 2007
Location: Cornwall, England
Posts: 1,421
Thanks: 18
Thanked 14 Times in 14 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
Personally I would use substr myself so you don't have to edit VB's tables. And then you could to a strreplace to remove images.
__________________
Yours is the Earth and everything that's in it
And - which is more - you'll be a Man my son!
|
|
|
October 13th, 2008, 05:31 PM
|
#9
|
|
Most Reputable Member
SuperMember
Join Date: Nov 2005
Location: webprocafe
Age: 28
Posts: 1,544
Thanks: 1
Thanked 11 Times in 11 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
I would rather not mess with the tables if its not needed..
its ok you guys saying what to use, but i am clueless on how to integrate it into the script
in the past, most php files I have tried to edit or change in any way, always end up with errors
would anyone be prepared to integrate it into the script that I have posted ? ( the code to include the text is already there, it just needs to be fitted and cut - if you get my meaning )
thank you
|
|
|
October 13th, 2008, 06:21 PM
|
#10
|
|
Most Reputable Member
Join Date: May 2007
Location: Cornwall, England
Posts: 1,421
Thanks: 18
Thanked 14 Times in 14 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
Would you not put $blog_text := substr($blog_text, 0, 20); I think, put it before:
Code:
$blog_text = $parser->do_parse($blog_text, $vbulletin->options['eft_bbcode_html'], $vbulletin->options['eft_bbcode_smilies'], $vbulletin->options['eft_bbcode_bbcode'], $vbulletin->options['eft_bbcode_img'], 1, 0); $blog_text = truncate($blog_text,100);
</span></span>
__________________
Yours is the Earth and everything that's in it
And - which is more - you'll be a Man my son!
|
|
|
October 13th, 2008, 07:13 PM
|
#11
|
|
Most Reputable Member
SuperMember
Join Date: Nov 2005
Location: webprocafe
Age: 28
Posts: 1,544
Thanks: 1
Thanked 11 Times in 11 Posts
Rep Altering Power: 0
|
Re: latest blogs problem
ok.. dont worry about limiting it, but i still need to remove the images so it takes the first so many words from the blog and displays it
the bit you gave me jack dont work - because its vbulletin, it gave me nothing.. the latest blog section just disapeared
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|