Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forums / Cotonti / Extensions / Support / Bug in comments extension

foxhound
#1 2012-09-07 15:38

No idea if this is already know, but there is a bug in the comments extension (latest Sienna version 0.9.11).
When you use the pagination to go to page 2 for example but you have the comments at the bottom of the page, not on top, the anchor link is wrong.

In the comments.functions.php the generated anhor link shows /xxxxxxx#comments#comments which is an invalid anchor and so it simply goes to the top of the page instead of the comments area.I fixed that by doing the following:

// A dirty fix for pagination anchors
			$pagenav['main'] = preg_replace('/href="(.+?)"/', 'href="$1#comments"', $pagenav['main']);
			$pagenav['prev'] = preg_replace('/href="(.+?)"/', 'href="$1#comments"', $pagenav['prev']);
			$pagenav['next'] = preg_replace('/href="(.+?)"/', 'href="$1#comments"', $pagenav['next']);
		}

Change to:

// A dirty fix for pagination anchors
            $pagenav['main'] = preg_replace('/href="(.+?)"/', 'href="$1"', $pagenav['main']);
            $pagenav['prev'] = preg_replace('/href="(.+?)"/', 'href="$1"', $pagenav['prev']);
            $pagenav['next'] = preg_replace('/href="(.+?)"/', 'href="$1"', $pagenav['next']);

I removed the "#comments" from the url creation as its already added by the function above this part.
Removing that fixed my comments issue and when I now click the pagination it automatically shows the area of my page where the comments actually are instead of the top.


PS:
I am not sure how you do prefer to recieve bug reports.
I know you have some system where you keep track of things and where people can post what they found but to be honest..........I dont understand so much how that works blush

 

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
pieter
#2 2012-09-08 05:38

I logged it here

... can we help you ...
foxhound
#3 2012-09-27 19:28

The same actually applies to the error message when posting a comment. By default the page redirects to the top of the page.
So, when someone makes a comment which goes wrong (for example try to submit an empty comment) the page refreshes to the top, but if you have the comments listed at the bottom (and so the error message as well) a user needs to scroll down to see the actual error message.

I tried to fix it myself and I found this line:

cot_redirect(cot_url($url_area, $url_params, '#c' . $id, true));

The #c is the anchor here, but if I replace it with one I am 100% sure works (cause I use it for all my other comment links) it still reverts to the top.
I tried removing Sid which is probably for the navigation but that too did not work.
If this is a confirmed bu I will add it to Github as well, can you please check?
And.........if you can is it possible to post how I can resolve this until an updated version is released?

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />