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

trouble using commentics in modx site
#1

First of all thanks for a great piece of work!

I do have some trouble getting it to work though, hope you can help me out here.

I am using modxcms from modxcms.com - the evolution version 1.05

In that I can define snippets of php code to be parsed and used by modx within pages.

I have tried this
<?php
$page_id = $modx->documentIdentifier;
$reference = $modx->documentObject['pagetitle'];
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>
And get this error message:
Comments
Please ensure that this page contains a Page ID in its file.

I am trying to see what happens here so I added something else to see if the page id is received from modx, as you can see below I //out the line require $path etc

<?php
$page_id = $modx->documentIdentifier;
$reference = $modx->documentObject['pagetitle'];
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
//require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
echo ( '<pre>' );
print($page_id);
print($reference);
echo ( '</pre>' );
?>
Now when I run this modx shows the page and in it shows the id and the pagetitle. So the modx code clearly works, but somehow the require bit screws things up.

I uploaded the example.php and that works ok, so commentics is installed ok, but it just can not be called from within cms generated pages - yet?

Any idea how to get this working?
Reply
#2

Hi,

That's odd. I've just had a look at the code which displays that error and it's very simple how it works. I'll try to explain it so it might help get to the issue. The integration code uses the require statement to include the file comments/includes/commentics.php into your page. In that file, on line 96, it calls the function cmtx_validate_page_id(). That function is in comments/includes/functions/page.php. The function will try to globalise the $page_id variable from your page so it has access to its value, it then checks whether it is there and that it's not empty, if it fails either of those then it displays the error message which you are seeing. Considering the tests that you did, my guess is that for some reason, perhaps due to MODx, the function (and probably all of the other Commentics functions too) are not able to globalise anything. It could also be to do with how your server is configured but doubtful if MODx is working fine.

Have you completed the interview?
Reply
#3

Steven,

Thanks for your reply, question is now what to do?

modx parses things and takes the snippet of code above and parses it and then renders the output.

I ma using other snippets of code with modx where modx has no problem finding included files, I guess the issue has to do with the global thing.

Below is a snippet of code that uses other files and that works with modx, in here you see a global statement as well:

<?php
include("login/config.inc.php");
global $_product_id;
$_product_id = array($products);
include_once("login/plugins/protect/php_include/check.inc.php");
?>

Could you come up with a variant of your code that has a global statement like above in it that would tell modx to let this be taken care of by commentics, as in the other snippet all work is done by the other external script.

thanks for thinking along.

Oliver
Reply
#4

Hi,

Have you tried globalising the variables of the integration code, like this:

PHP Code:
<?php
global $page_id, $reference, $path_to_comments_folder;
$page_id = "1";
$reference = "Page One";
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>

Have you completed the interview?
Reply
#5

Thanks, I just gave that a try, like below:
<?php
global $page_id, $reference, $path_to_comments_folder;
$page_id = $modx->documentIdentifier;
$reference = $modx->documentObject['pagetitle'];
$path_to_comments_folder = "comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
echo ( '<pre>' );
print($page_id);
print($reference);
echo ( '</pre>' );
?>
And now I just get a blank page...

I might have to try pulling it in via javascript and a separate page and a special div on the page, will try that now.

Bit clueless about this with modx, help much appreciated!
Reply
#6

I just tried pulling the commentics funcionality into a special div on my page with a javascript.

The javascript pulls the separate example.php into a div on the page with window.onload.
No trouble getting the commentics example page to show, but when I add a comment I get this result:

Comments
You have just been banned.

This can be due to a variety of reasons including swearing, spamming and hacker-related behaviour.

If you feel that this was in error, please contact the administrator, quoting your IP Address.

Interesting...

I logged in on the backend and see the reason for the ban is given as Incorrect referrer...

Any way to fix this?
Reply
#7

(27-Oct-2011, 02:07 PM)olliejames Wrote:  I just tried pulling the commentics funcionality into a special div on my page with a javascript.

The javascript pulls the separate example.php into a div on the page with window.onload.
No trouble getting the commentics example page to show, but when I add a comment I get this result:

Comments
You have just been banned.

This can be due to a variety of reasons including swearing, spamming and hacker-related behaviour.

If you feel that this was in error, please contact the administrator, quoting your IP Address.

Interesting...

I logged in on the backend and see the reason for the ban is given as Incorrect referrer...

Any way to fix this?

OK, I jsut deleted the ban and found I can turn off the refferer check, but that still does not take me anywhere, because now it just links the comments to the page that is included via the javascript...
Reply
#8

Hi,

The referrer check is a little sensitive. It's improved in the next version.

I'm not sure how to help you with this MODx issue. Commentics works but MODx seems to be parsing it in a way that is stopping it from working. Whether that's due to the code for Commentics being at fault (there is nothing obvious which I can think of) or that MODx is not parsing it properly, it's difficult to say as I've never used their script and I don't have enough time available to learn it. It may be an option to include Commentics without using their parser. That's the only suggestion I can offer at the moment.

Have you completed the interview?
Reply
#9

(27-Oct-2011, 08:52 PM)Steven Wrote:  Hi,

The referrer check is a little sensitive. It's improved in the next version.

I'm not sure how to help you with this MODx issue. Commentics works but MODx seems to be parsing it in a way that is stopping it from working. Whether that's due to the code for Commentics being at fault (there is nothing obvious which I can think of) or that MODx is not parsing it properly, it's difficult to say as I've never used their script and I don't have enough time available to learn it. It may be an option to include Commentics without using their parser. That's the only suggestion I can offer at the moment.

Hello Steven,

How can I use commentics without parser?

I have also asked on the modx forum, hopefully someone there know more, if so, I will report back. But please let me know how to use it with an iframe or javscript include if you can.

thanks

Oliver
Reply
#10

(26-Oct-2011, 07:34 PM)Steven Wrote:  ... doubtful if MODx is working fine.

Sad I had MODX installed on a dedicated server and it destroyed everything, we needed 2 days to try cleaning out the server and ended up wiping it completely clean and re-install everything from scratch... I'd say it's a bad hack wrapped in new shiny paper - maybe that helps answer questions about MODX ;-)
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
23-Apr-2012, 05:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)