![]() |
first x words
I've written a some scripts to pull out posts from specific forums to display on non-vb pages, but am having trouble cropping the sentence for display on the article listing page. If you want to see my problem, go here http://www.numbmonkey.com. Basically, I want the title and the first x words displayed. I've tried two different functions to crop at x characters or x words, but they have a tendancy to cut URL links in half. How can I crop after so many words with busting the vbulletin URL tags.
Here are the two scripts I tried (first one adds a nice "..." after crop): PHP Code:
PHP Code:
Thanks, -Matt |
While it's not exactly what you want, why not just try PHP's http://www.php.net/wordwrap function?
|
Thanks for the idea of using wordwrap. It sort of worked by keeping the long URL's from breaking the design, but it didn't fix them not getting converted into a usable link. In my text format function, I have it convert the vbulleting [URL] tag into an html link. I think that the way my cropsentence function (seen in my first post) is working is preventing this conversion from working correctly.
Here's what I use to convert the [URL] into a link: PHP Code:
|
Side note: use the preg (preg_replace) instead of the ereg (ereg_replace) functions for speed.
If these non-vB pages have global.php included, you can just use the bbcodeparse2() function to do all the work. :) |
Oh man ... you gotta be kidding. Here I am banging my head against the desk trying to figure out how to do this and I could have been using bbcodeparse2? Can you give any guidance on how to use it? I found the function but am not sure what I have to pass into it?
Thanks! -Matt |
Can anyone explain how to use the bbcodeparse2() function? What variables to I have to pass into it?
|
Look at the header for it...
|
PHP Code:
PHP Code:
|
All times are GMT. The time now is 11:04 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|