PDA

View Full Version : [Read More] cutoff... Eats tables, crushes small buildings. Other solutions?


StewardManscat
07-21-2004, 08:24 PM
I allow HTML in the news.

I used a table to display an image next to the copy.

Later, I decided I was too wordy, and I should take advantage of the "read more" option.

Oh my goodness... of course cmps only displays a partial table, and the remainder of the news page was destroyed, as the ending </td> tag did not make it into the news.

Okay, I can fiddle with that. But it strikes me as fiddling with fire. Too easy to break again later.

Just wondering if anyone else had encountered this and developed a good solution.

I think maybe CSS can do it, but it's been a long time for me... I vaguely recall reading that CSS positioning logic was not always dependable across browsers.

* * * Later that same day... * * *

Using a word count for cutoff is arbitrary, and strips the author of editorial control.

It is more important that lead items cut off at an intelligent point, rather than each item having the same length.

This would shoot the table problem, and put control squarely back in the hands of the editor.

I almost got excited about this, but fell down and bloodied my nose:

At the very end of parsebbcode2 (functions_bbcodeparse.php) I added:


global $newsItem;
if ($newItem)
$bbcode = str_replace('[ReadMore]', '', $bbcode);



In modules/news.php I replaced


$news['message'] = parse_bbcode2($news['pagetext'], $vba_options['portal_news_enablehtml'], $vba_options['portal_news_enablevbimage'], $allowsmilie, $vba_options['portal_news_enablevbcode']);

if ($vba_options['portal_news_maxchars'] AND strlen($news['message']) > $vba_options['portal_news_maxchars'])
{
$news['message'] = fetch_trimmed_title($news['message'], $vba_options['portal_news_maxchars']) . construct_phrase($vbphrase['read_more'], $vboptions['bburl'], $news['threadid'], $session['sessionurl']);
}


with:


// Signal bbparser NOT to strip the [ReadMore] tag
$newsItem=true;

// Parse the string normally, but leave my [ReadMore] in place
$news['message'] = parse_bbcode2($news['pagetext'], $vba_options['portal_news_enablehtml'], $vba_options['portal_news_enablevbimage'], $allowsmilie, $vba_options['portal_news_enablevbcode']);

$i=strpos($news['message'], '[ReadMore]');
if ($i>0)
// Truncate the item
$news['message'] = substr($news['message'],0,$i) . construct_phrase($vbphrase['read_more'], $vboptions['bburl'], $news['threadid'], $session['sessionurl']);


... remembering to unset $newsItem at the end of the script.

Works ok, but using globals to control bbparse behaviour srtikes me as something no well-mannered coder would do. Having no manners at all, I can live with it. But I am betting there is a guru at this forum (ahem) who knows so much more about vb than me, he may suggest a safer, easier, well-lit, sanctioned and government-approved route to go.

Thank you for listening.

Brian
07-21-2004, 09:05 PM
That method looks fine to me. For most people the current system works well enough, and doesn't require modification to any additional files, so that's why we use the method we are now. ;)

Our Sponsors
 

StewardManscat
07-23-2004, 10:54 AM
Durn. Was hoping you would be dazzled.

But others are having problems. Today I found two threads on problems breaking the news over quotes, which was perhaps where I should have posted.

Please consider something like this (I know you can do it better) for a next release.

It is very convenient to have total control over the break.

In terms of sales and marketing it means we can write to snare.

And in webmaster terms it can avoid the html/quotes/flow problem which does not happen for most people.

Smiling at you.

Brian
07-23-2004, 01:06 PM
I should have a solution for quote and php tags breaking the display in the next version, but it's doubtful there will be anything for HTML (that would probably require too much to do it in the CMPS files, or modifying more default vBulletin files, which I'm trying to stay away from. ;))