PDA


View Full Version : Problem with News Module and QUOTEs


Nick@NASIOC
09-02-2006, 08:29 PM
I just found a very strange error today. I am still in the testing stages of setting up vBadvanced, and today when I pointed the news forum at a pre-existing forum on my site I was getting all sorts of html rendering issues.

http://www.nasioc.com/uploads/vbaissue.gif

When I change the forum to point to another forum without quotes in the first 5 messages, which is what I'm pulling for news, the pages renders perfectly normal. But it appears that as soon as the quote tag is involved, and I think when it's being truncated because of the 500 char limit it's causing this issue.

When I pull the exact same forum as show above in the graphic, but remove the 500 char limit on the new posts, it renders fine. So as far as I can tell it's definitly related to the quote tag interfereing with the table structure.

I am also running the stock module setup... this image was a crop of the browser so you can't see the left column. The right column however is what you see embedded into the threads on the lower right corner.

If you want to see how the rest of the page renders you can view it here: http://www.nasioc.com/uploads/vbaissue2.gif

Please let me know what I can offer you guys to help troubleshoot the problem faster. Thanks in advance.

-Nick
http://www.nasioc.com/

Zachery
09-03-2006, 08:26 AM
Its a very old issue that we haven't found a good way to deal with yet, altho someone did suggest an easy way to fix it they did not provide us with the fix :/


The best bet is to allow enough characters for any of your posts.

Nick@NASIOC
09-03-2006, 03:46 PM
Its a very old issue that we haven't found a good way to deal with yet, altho someone did suggest an easy way to fix it they did not provide us with the fix :/


The best bet is to allow enough characters for any of your posts.

Thanks for getting back to me...

Hmmm... the problem is we were going to use the news module for actual news articles from a magazine that will be working with our site. So I wanted a short intro to display and allow the members to read the rest of the story at their choosing.

I suppose we can just make sure not to use quotes in those articles.

Is there a fix in the works? Or is this a holding pattern sort of bug?

Zachery
09-04-2006, 01:59 AM
Like I said, there was someone who had a fix but did not provide it with us. I know its something we want to fix but haven't had a good way to avoid it.

FortyJ
09-13-2006, 02:27 PM
I'm barely familiar with PHP, but couldn't we add some script into the News Module template that would automatically replace all instances of with , or something like that?

Brian
09-13-2006, 03:20 PM
Not quite that easy... You can try this method though:

Open your includes/vba_cmps_include_bottom.php file and look for this line (right at the top):
error_reporting(E_ALL & ~E_NOTICE);

Below that, add this:
// ##### Check and end HTML tags in news posts.
function check_string_html($text, $startstring, $endstring)
{
$stablecnt = substr_count($text, $startstring);
$etablecnt = substr_count($text, $endstring);

while ($stablecnt > $etablecnt)
{
$etablecnt++;
$text .= $endstring;
}

return $text;
}

Then look in your modules/news.php file for this code:
// Strip characters and add "read more"
if ($mod_options['portal_news_maxchars'] AND strlen($news['message']) > $mod_options['portal_news_maxchars'])
{
$news['message'] = substr($news['message'], 0, strrpos(substr($news['message'], 0, $mod_options['portal_news_maxchars']), ' ')) . '...' . construct_phrase($vbphrase['read_more'], $vbulletin->options['bburl'], $news['threadid'], $session['sessionurl']);
}


Replace it with this:
// Strip characters and add "read more"
if ($mod_options['portal_news_maxchars'] AND strlen($news['message']) > $mod_options['portal_news_maxchars'])
{
$news['message'] = substr($news['message'], 0, strrpos(substr($news['message'], 0, $mod_options['portal_news_maxchars']), ' '));

$news['message'] = check_string_html($news['message'], '<div', '</div>');
$news['message'] = check_string_html($news['message'], '<td', '</td>');
$news['message'] = check_string_html($news['message'], '<tr', '</tr>');
$news['message'] = check_string_html($news['message'], '<table', '</table>');
$news['message'] = check_string_html($news['message'], '<table', '</table>');

$news['message'] .= '...' . construct_phrase($vbphrase['read_more'], $vbulletin->options['bburl'], $news['threadid'], $session['sessionurl']);
}


Upload those two files, and that should take care of the problem. :)

Note that this may not be the prettiest solution and there's still a chance that your pages will not pass XHTML validation. It is, howerver, very easy on a server and should prevent any visible problems.

FortyJ
09-13-2006, 06:13 PM
Where's that :falling_over_backwards_crosseyed smilie? Thanks. I will definitely try that, but just not right now. I've already spent too much time today restoring service to my site for some other issue. For now, though, I'm going to relax and think of anything but php. :)

Quarterbore
09-14-2006, 04:19 PM
I just discovered this problem on my site and I was convinced I caused it... after a few hours of looking at my code and truning off all the modules I figured out that only the news module is causing this....

Search here and well... I could have saved a lot of time starting here!

I will try to fix my site using this tonight if I can... Thanks for the fix even though I didn't need to ask for help!

voteforbird
09-15-2006, 04:33 PM
Why wouldn't the code pass validation with this fix? What does the fix actually do?

Brian
09-17-2006, 02:13 PM
It does 4 separate checks to count the number of opening/closing <div>, <td>, <tr>, and <table> tags in each news post. If it counts more opening tags than closing ones, then it adds the missing closing tag. The method may not work *perfectly* in cases where there are multiple quotes in one news post though since a tag could be closed before it technically should according to XHTML standards. But even in those cases, all browsers I've tested with still display the text without any visible problems. And that could still only happen if it has to cut off more than one [quote] tag in the news preview, so it should be fairly rare to even have any "invalid" code. So while it's not perfect, I think it's a good solution as it does what it's supposed to, and most importantly, without adding any significant extra strain to your server. ;)

Blaque_Out
09-20-2006, 06:10 PM
I've been having this problem, and used this fix. However now I have a problem where my news module expands the entire page, and my right side modules are expanded and centered directly underneath.

I'll try working more on this later.

mecho
09-30-2006, 06:18 PM
see this picture ... and attention to Read More of each post .

http://i10.tinypic.com/4cm8u8p.jpg

Brian
10-01-2006, 06:33 PM
Blaque_Out - Can you post a link to your site so I can get a better idea of the problem?

mecho - The site you posted the image on seems to be down. Can you attach it here instead?

Primeval
10-01-2006, 10:20 PM
Blaque_Out - Can you post a link to your site so I can get a better idea of the problem?


Visit:

http://www.weedtalk.com/index.php?page=wtf

http://www.weedtalk.com/wtf.jpg

Because I'm having the same problem myself. ANY custom modules will "push" the middles to the below the left column and the right column gets pushed to the bottom.

I've found a couple more "bugs" too...

http://www.weedtalk.com/missinglink.jpg

I'm starting to like and dislike CMPS 2.2 at the same time. Sometimes I perfer the old 1.0 version but It may not work on the 3.6.x versions :(

Brian
10-01-2006, 10:26 PM
Visit:

http://www.weedtalk.com/index.php?page=wtf

http://www.weedtalk.com/wtf.jpg

Because I'm having the same problem myself. ANY custom modules will "push" the middles to the below the left column and the right column gets pushed to the bottom.
Looks like that's due to some invalid code in your custom modules. You can try turning the "Use Module Shell Template" option off for those modules to see if that helps.

I've found a couple more "bugs" too...

http://www.weedtalk.com/missinglink.jpg

I'm starting to like and dislike CMPS 2.2 at the same time. Sometimes I perfer the old 1.0 version but It may not work on the 3.6.x versions :(
Admin CP => vBa CMPS => Edit Pages => {page name}

Go there and make sure the Site Navigation setting there has the same values. If not, that means you've customized it for that page, so the default settings for the module are not going to have an effect. You can either use the "Use Default" checkbox to revert to using the default setting, or just change it for that page instead.

Primeval
10-01-2006, 10:41 PM
Looks like that's due to some invalid code in your custom modules. You can try turning the "Use Module Shell Template" option off for those modules to see if that helps.

That did the trick. I wonder why it causes that problem?


Admin CP => vBa CMPS => Edit Pages => {page name}

Go there and make sure the Site Navigation setting there has the same values. If not, that means you've customized it for that page, so the default settings for the module are not going to have an effect. You can either use the "Use Default" checkbox to revert to using the default setting, or just change it for that page instead.

I found that out before you answered the solution.. I didn't notice that tiny small box that didn't use the default settings.. I was going to 3 different pages at once and was getting annoyed.

Brian
10-01-2006, 10:44 PM
The module_shell template basically has some code like this:

<table>

$content

</table>


Then any modules which use that template should start with a <tr> and <td> tag containing the content. Otherwise, they can break. ;)

GITs
10-02-2006, 12:41 PM
just logged into my site and found exactly the same situation... basically its where a new table for the quote is started but not properly closed... if vBa can make sure that before they cut off the characters and display the read more link that no table has been started but not finished, this should be fixable...

Brian
10-02-2006, 12:58 PM
GITs - A fix is posted in post #6 in this thread. ;)

mecho
10-02-2006, 06:02 PM
mecho - The site you posted the image on seems to be down. Can you attach it here instead?


Image attached . and here also is my link
http://mechodownload.com/forum/cmps_index.php

Brian
10-02-2006, 07:11 PM
And you're still getting this problem after applying the fix posted in post #6 in this thread?

mecho
10-03-2006, 02:36 PM
yea .. i edit those .php files ( in order post #6 ) but iam still have that problem !

KW802
10-03-2006, 03:00 PM
Then any modules which use that template should start with a <td> tag containing the content. Otherwise, they can break. ;)Um..... I thought the templates needed <tr><td>{content}</td></tr> and not just <td>{content}</td>?

Brian
10-03-2006, 04:15 PM
mecho - Would you mind submitting a support ticket via the Members' Area here so I can have a look?

Kevin - Uhhh... I don't know what you're talking about.
*Edits his posts and walks away whistling*