This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Permalinks
#1

First off, I want to say: great script! It has exactly what I need. I want to use it as a review page for my writing performance.

However, I see a feature missing that I think should be in place: permalinking comments.

This way, I can link to another comment in reference while making replies, or to simply link to a thread to show someone the discussion.

-Tarak
Reply
#2

Hi,

Thanks, I think this is an important feature. I have added it to the Roadmap:

http://www.commentics.org/roadmap.php

Have you completed the interview?
Reply
#3

Thanks for adding the permalinks!

I was wondering why the permalink looks like this:

mydomain.com/someValue/anotherValue/?variable1=someValue&variable2=anotherValue&cmtx_perm=14#cmtx_perm_14

.htaccess already tells the rewrite engine that: /someValue/anotherValue/
means variable1=someValue and variable2=anotherValue

so is there any way to simplify the Commentics permalink to something like:

mydomain.com/someValue/anotherValue/?cmtx_perm=14#cmtx_perm_14

Thanks,
Jake
Reply
#4

Hi Jake,

The permalink URL is constructed using the URL from Manage -> Pages in the admin panel. Can you check the URL there and edit it if it contains the variable1=someValue part.

As to why the URL was like that in the first place, it must have been the automatic page creation function in /comments/includes/functions/page.php. The code responsible there is as follows:

PHP Code:
<?php 
$url
= "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . strtolower($_SERVER['SERVER_NAME']) . $_SERVER['REQUEST_URI'];

The $_SERVER['REQUEST_URI'] part is the part which gets everything after mydomain.com. As far as I know, $_SERVER['REQUEST_URI'] effectively gets exactly what's in the address bar of the web browser, so it should be friendly with a URL that has been re-written and shouldn't be getting the variable1=someValue part. I'm not a big fan of URL re-writing so I don't have any scripts that I can test with. But in theory it should work, as this article explains:

Quote:"In all of our examples, this returned exactly what we entered for the URL."

Have you completed the interview?
Reply
#5

Hi Steven,

Thanks for getting back to me.

I replaced your

PHP Code:
<?php 
$url
= "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . strtolower($_SERVER['SERVER_NAME']) . $_SERVER['REQUEST_URI'];

with

PHP Code:
<?php 
$url
="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

which is what i use to get the full exact url in the address bar. I get the same results either way.

I just noticed that when I have absolutely no comments at all in the db, when I make my first comment, it creates two entries in Manage=>Pages, one with the funny url and one with the normal one. It makes only comment and that comment only appears if the strange url is in the address bar.

Any ideas?
Thanks
Reply
#6

Okay, there are a couple of things to look into, one of which is related to the Like/Dislike feature not working.

1. After you submit the 'Add Comment' form, is the URL different? If so, try this:
http://www.commentics.org/forum/showthre...44#pid3944

2. The like/dislike feature may not be working because your URL re-write code is re-writing the URL to the /comments/vote.php file. This URL is on line 195 in /comments/includes/template/comments.php.

PHP Code:
<?php 
url
: "<?php echo $cmtx_path . "vote.php"?>",

At runtime, once the PHP is parsed, it should result in:

PHP Code:
<?php 
url
: "comments/vote.php",

However your URL re-write may be malforming it. To check, you could try replacing it with the absolute URL:

PHP Code:
<?php 
url
: "http://www.yourdomain.com/comments/vote.php",

Note that it's very important that if you put the www in there, then www has to be in the URL in your web browser's address bar. Also, if you put http in there, then http has to be in the address bar and not https. This is why I used a relative URL when coding it, because it avoids the need to match whether the www and http(s) is there. Ajax is really picky about it due to security.

Have you completed the interview?
Reply
#7

Wow Thanks!
I didn't get around to fixing the like/dislike, but the instructions in #1 worked great. It looked like Sabrina was having the same problem (php parameters showing up after the permalink). I don't know what that extra line does, but it worked great .
Thanks!
Reply
#8

(28-Feb-2013, 07:17 PM)Steven Wrote:  1. After you submit the 'Add Comment' form, is the URL different? If so, try this:
http://www.commentics.org/forum/showthre...44#pid3944

I did what you said over their and it worked great. There seems to be a different effect though:

The permalink for a comment is now:

http://www.domain.com/Article-Name/?cmtx...mtx_perm_5

If I open that url, the page has no comments. The url that does show the comments and will go directly to the comment associated with the permalink is

http://www.domain.com/Article-Name/#cmtx_perm_5

but it's not getting written that way.
Reply
#9

(28-Feb-2013, 08:39 PM)JMG Wrote:  I don't know what that extra line does, but it worked great .

$_SERVER['QUERY_STRING'] just gets any parameters that are in the URL. The reason I added this was in case the website has any features that alter the URL. It's probably best to give an example. If you go to the demo, click the 'Alternate' link, notice that 'style=alternate' is in the URL, now click on the page 2 pagination link. You'll see that 'style=alternate' is still in the URL. This could be useful for example if your website has a feature to change the language or to change the sort order of something, Commentics will remember and retain it. However, what seems to be happening is that $_SERVER['QUERY_STRING'] is getting the parameters from the URL before it is re-written and aren't actually even in the URL. So, the suggestion I made just clears the $_SERVER['QUERY_STRING'] value so there's nothing in it. This will get rid of the parameters that were in your original URL but it will now no longer provide the advantage of retaining any additional parameters, so it's not ideal. What I'll try to do for the next version is instead of using the $_SERVER['QUERY_STRING'] value, I'll use $_SERVER['REQUEST_URI'] which gets what's actually in the URL, and extract the parameters from that.

Have you completed the interview?
Reply
#10

(28-Feb-2013, 11:23 PM)JMG Wrote:  I did what you said over their and it worked great. There seems to be a different effect though:

The permalink for a comment is now:

http://www.domain.com/Article-Name/?cmtx...mtx_perm_5

If I open that url, the page has no comments. The url that does show the comments and will go directly to the comment associated with the permalink is

http://www.domain.com/Article-Name/#cmtx_perm_5

but it's not getting written that way.

"?cmtx_perm=5#cmtx_perm_5" is the correct URL. There needs to be the cmtx_perm=5 part so that the script can calculate what page to load. Having #cmtx_perm_5 without cmtx_perm=5 might work for now but once you have multiple pages it won't. I'm not sure why it's not displaying any comments. I assume you're using the cmtx_url keyword for the $cmtx_page_id variable in your integration code, so what's probably happening is that the URL is different to the one in Manage -> Pages so it's creating a new page which has no comments. The code which handles the automatic new page creation knows to remove ?cmtx_perm=5 from the URL before checking to see if it already exists in Manage -> Pages so it should be able to deal with that. But it might be better to supply the $cmtx_page_id variable with a more reliable value, maybe supply it with just the variable1=someValue or variable2=anotherValue part of the URL, instead of the whole thing.

Have you completed the interview?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)