×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Different comments for html GET variables

Different comments for html GET variables 8 years 2 months ago #22536

  • Kevin Steely
  • Kevin Steely's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
I have a joomla site that will display dynamic data based on variables in the url: i.e. mywebsite.com/test.php?var1=3.

Is there anyway to have this plugin recognize the var1=3 vs. var1=2 and display comments according to the GET variable? Or is it strictly based on the "joomla article?"

Thanks for any advice.

Different comments for html GET variables 8 years 2 months ago #22546

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
It is strictly based on the joomla article and it supports #!/ccomment-comment=id and
#!/ccomment-page=id

Regards,
Daniel

Different comments for html GET variables 8 years 2 months ago #22553

  • Kevin Steely
  • Kevin Steely's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Can you explain what these are and how to use?

#!/ccomment-comment=id and
#!/ccomment-page=id

Searching google, support documentation, and this forum returns nothing for these.

Thanks!

Different comments for html GET variables 8 years 2 months ago #22631

  • Kevin Steely
  • Kevin Steely's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Ok, I've been playing with this a lot and almost have it working but can't figure out this last step. I've changed the code a bit to store the exact URL as the contentid in the database (probably a better way to do this but for now I'm just testing). This works... if I hit save, the data is entered into the database as expected. If I refresh the page, however, it will count the number of comments correctly and show the count correctly. However, it never loads a comment.

I -believe- I've narrowed this down to:

media/com_comment/js/collections/comments.js

and more specifically the following &task=comments.getcomments&format=json&contentid='+compojoom.ccomment.item.contentid+'

The compojoom.ccomment.item.contentid is -always- showing a 0 when I look at the access log. If you could point me in the right direction for how/where this is generated, then I should be able to get everything working the way I need.

Thanks for any help.

Different comments for html GET variables 8 years 2 months ago #22633

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
if you look at the head of your page you'll see that there is a var compojoom = ... object that contains the contentid. This is generated during a page load and the contentid is actually nothing else than the current article id. Once the page is loaded we call the getcomments function and pass it the contentid in question.

In your case you are talking about get variables, so I would imagine that instead the contentid there you would read the browser url and get the variables from there?

Different comments for html GET variables 8 years 2 months ago #22635

  • Kevin Steely
  • Kevin Steely's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Ok, found where to change it. You are right, I'm grabbing the variables from Jinput, appending them to the JURI::current() var which gives me the exact page I am on.

Initially, I changed the contentid in the db to a string and updated xmls and forms to process it as a string. This didn't work, so now I hash it to numbers only.

Still giving me the same problem for some reason:

Here is the object in the header:

item: {"contentid":794432140510795178,"component":"com_content","count":1},

However, same behavior is occurring. It adds the comment to the db correctly, with the exact contentid the compojoom.ccomment var is reading in on a page load, but it gets stuck at "loading comments." You can see that it even knows there's a comment there for that contentid, but the comments never load.

I must be missing something here.... so close.

Different comments for html GET variables 8 years 2 months ago #22659

  • Kevin Steely
  • Kevin Steely's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Ok, well, I started from scratch and got it working keeping the contentid as an int.

Here's the code in case someone else needs something like this... will probably streamline this later, but this works for now. Obviously, for what I need this for, I know exactly how the URL will be formed and what variables will be there which is why you see some of the code that you will see. But you should be able to figure this out for your own site should you need.

This will also keep the normal contentid as the article id if the preg_match() doesn't match an article you specify.

in "administrator/components/com_comment/library/component/plugin.php":

change the getPageId() function to the following:
public function getPageId()
        {
                // edited
                //return $this->row->id;
 
                // get pathname of url
                $u = JURI::current();
                $url = JURI::getInstance($u);
                $url = $url->getPath();
 
                // match on article names
                if (preg_match("/abcde/", $url)) {
                        $jinput = JFactory::getApplication()->input;
                        $var1= $jinput->get('var1');
                        $var2= $jinput->get('var2');
                        $var3= $jinput->get('var3');
 
                        if ($var1!= NULL) $url .= "?var1=" . $var1;
                        if ($var2 != NULL) $url .= "&var2=" . $var2;
                        if ($var3!= NULL) $url .= "&var3=" . $var3;
 
                        // use crc32() to return an int
                        $retval = crc32($url);
 
                }
                else {
                        $retval = $this->row->id;
                }
                return $retval;
        }
  • Page:
  • 1
Time to create page: 0.164 seconds