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

Loading comments dynamically

Hello Steve.
Glad you are still there.
BTW: Is this where I'm supposed to reply each time? I don't se any way to format or attach anything.
The setup of the page where articles are loaded is exactly the same locally and remotely. 
I have used window.location to make that possible.
Yes, of course, I have made sure that the identifier and reference are correct in the dev tools. And they definitely are.
But just to make sure, I have deleted those 2 articles and reposted them.

Now, when I refresh the page or click on a link I get the iframe for a first comment, so far so good.
So I enter a comment for two articles only: Awakening and Egoic Mind; I leave the article “Yoga” without comments.
Each time I get an email saying that I have successfully posted a comment.

At the Back end:
There are two articles posted: 
1. Awakening: identifier: awakening; reference: Awakening; url:; (form enabled; all permissions ok, approved)
2. Egoic Mind: identifier: egoic-mind; reference: Egoic Mind; url:; (form enabled; all permissions ok, approved)

To me, this all seems very good.
Yet, whether I refresh the page or load a different article, no iframe, except when there are no comments (in this case for the article “Yoga”).
Again, locally, this all works fine.

Would you please go to: and check that out for yourself. I am probably missing something but I just can’t figure it out. I have written some logs to produce each time the identifier and reference.
By the way, I have tried the same code for one of my official commented pages, and the exact same issue is repeated there as well: works locally, not remotely.

Here is my code (slightly altered since the last time).



var defaultArticle = localStorage.getItem('defaultArticle');

defaultArticle = defaultArticle === null || defaultArticle === '' || defaultArticle === 'undefined' ? 'egoic-mind' : defaultArticle;

$('#textContainer').load('text/articles/' + defaultArticle + '.htm', function() {

/* ************************** */

// NOTE: load article from clicking on link
function loadNewArticle(ident) {
$('#textContainer').load('text/articles/' + ident + '.htm');
// $('#commentics iframe').hide(); // NOTE: was here by my mistake; no longer 

/* ************************** */

var wl_protocol = window.location.protocol;
var wl_host =;
var wl_path = window.location.pathname;
var wl_address = wl_protocol + '//' + wl_host + wl_path;
var wl_localfolder = wl_host.match('^localhost') ? '/YIMind-dev' : '';
var wl_start = wl_protocol + '//' + wl_host + wl_localfolder;
var ident, refer, url, iFrame;

// NOTE: load comments based on default article in localStorage
//function loadComments() {
var loadComments = function() {
ident = $('#post_id').val();
refer = $('#post_id').attr('title');

iFrame = document.getElementById('cmtx_iframe');

url = wl_start + '/commentics/iframe.php?identifier=' + encodeURIComponent(ident) + '&reference=' + encodeURIComponent(refer) + '&url=' + wl_address + '#' + encodeURIComponent(ident);// + '%3Fb%3Darticles%26f%3D%26s%3D%26d%3D' + encodeURIComponent(ident);

console.log('loading IDENTIFIER: ' + ident + ' | loading REFERENCE: ' + refer);

console.log('URL: ' + url);

iFrame.src = url;

$('#commentics iframe').delay(300).fadeIn(600);

function updateComments(ident, refer) {

iFrame = document.getElementById('cmtx_iframe');

console.log('>>> IFRAME from UPDATE: ' + iFrame);

url = wl_start + '/commentics/iframe.php?identifier=' + encodeURIComponent(ident) + '&reference=' + encodeURIComponent(refer) + '&url=' + wl_address + '#' + encodeURIComponent(ident);// + '%3Fb%3Darticles%26f%3D%26s%3D%26d%3D' + encodeURIComponent(ident);

console.log('URL: ' + url);

iFrame.src = url;

$('#commentics iframe').delay(300).fadeIn(600);

console.log('>>> updated (link) IDENTIFIER: ' + ident + ' | updated (link) REFERENCE: ' + refer);

// NOTE: update default article in localStorage
localStorage.setItem('defaultArticle', ident);



Thank you.

There could be an error happening. Can you try this FAQ:

Have you completed the interview?

Hello again.
Just as you mentioned there might be an error I was indeed noticing an error in the console when I add a comment. Commentics tells me that my comment has successfully been added (true enough, I see it in the back end and I receive an email to that effect). However...

In the Error Log of the backend, after I either refresh the page, click on a link, or add a comment, I see:

[20-Jul-2021 14:25:57 America/Vancouver] PHP Parse error: syntax error, unexpected '$_' (T_VARIABLE) in /hermes/bosnacweb01/bosnacweb01at/b1876/nf.yilivca/public_html/YIMind/commentics/frontend/view/yim-front/language/english/part/notify.php on line 18
[20-Jul-2021 14:26:06 America/Vancouver] PHP Parse error: syntax error, unexpected '$_' (T_VARIABLE) in /hermes/bosnacweb01/bosnacweb01at/b1876/nf.yilivca/public_html/YIMind/commentics/frontend/view/yim-front/language/english/part/notify.php on line 18

When I add a comment (can only do this if there aren’t any comments yet for any given article; once the comment has been accepted and successful the iframe doesn’t show up), I get this error in my browser’s console (never gets such error otherwise):

common-jq.min.js?1625955248:1 POST 500 (Internal Server Error)
send @ common-jq.min.js?1625955248:1
ajax @ common-jq.min.js?1625955248:1
cmtxRefreshComments @ common-jq.min.js?1625955248:1
(anonymous) @ common-jq.min.js?1625955248:1
a @ common-jq.min.js?1625955248:1
fireWith @ common-jq.min.js?1625955248:1
l @ common-jq.min.js?1625955248:1
(anonymous) @ common-jq.min.js?1625955248:1
load (async)
send @ common-jq.min.js?1625955248:1
ajax @ common-jq.min.js?1625955248:1
(anonymous) @ common-jq.min.js?1625955248:1
dispatch @ common-jq.min.js?1625955248:1
g.handle @ common-jq.min.js?1625955248:1
common-jq.min.js?1625955248:1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>

Okay so it's because there's a syntax error in /frontend/view/yim-front/language/english/part/notify.php on line 18. You'll need to open that file and correct the syntax. If you're not sure just paste the contents of the file here (shouldn't be many lines).

Have you completed the interview?

I looked at the file in question, but can't figure out what syntax error it has. Can you? Here it is. Line 18 is "$_['lang_error_disabled'] = 'This feature is disabled';".

// Heading
$_['lang_heading_notify'] = 'Notifications';

// Title
$_['lang_title_notify'] = 'Notify me of new comments via email';
$_['lang_title_cancel_notify'] = 'Cancel this notification';

// Text
$_['lang_text_notify'] = 'Notify Me';
$_['lang_text_notify_info'] = 'Notify me of new comments<span class="cmtx_info_extra"> via email</span>';
$_['lang_text_notify_success'] = 'A confirmation email has been sent to you';

// Link
$_['lang_link_cancel'] = 'Cancel'

// Error
$_['lang_error_disabled'] = 'This feature is disabled';
$_['lang_error_subscribed'] = 'You are already subscribed to this page';
$_['lang_error_pending'] = 'You have a pending subscription';
$_['lang_error_review'] = 'Please review the errors below';

// Button
$_['lang_button_notify'] = 'Subscribe';
$_['lang_button_processing'] = 'Please Wait...';

You're missing a semicolon after $_['lang_link_cancel'] = 'Cancel'

Have you completed the interview?

Unbelievable!... but true.
How could I have missed this? I guess it's in part because there was no such issue locally.
Anyway, thanks so much. It works!, and that's what matters.

Unfortunately, there is still something (I know, bummer!). I have written my navigation codes based on the window location. Now, when I navigate to either a previous or a forward page, the page itself doesn't change (nor the url of the page), only the comments change.

So my question is: how do I ensure that when I navigate through the pages the actual page will change (which should also change the comments accordingly)? Or can a similar approach as the one you have given me be implemented with the php integration?
I may only be able to check the forum again in a day or two. Meanwhile, if you come up with a way to accomplish this, that would be awesome.
In fact, I must say, you have been awesome throughout this whole interview, very commendable.
Steven, thank you very much.

Hi Steven. I recently left a “quick reply” to your last reply regarding the error that I was getting when posting comments on the remote site. I’m not sure which kind of reply I’m supposed to do each time. Do you read/answer both “quick” and “new” replies? Are they basically the same or should one be used preferably to the other in order to get a reply?
Anyway, I want you to know that it was in fact just a semicolon missing after $_['lang_link_cancel'] = 'Cancel'. 
So now the comments load correctly both from a page refresh and a click on a link. Wonderful. Thanks.

However, when I navigate to either a previous or a forward page, the contents of the page itself (i,e, the article) doesn't change (nor the url of the page), only the comments change.
So my question is: how do I ensure that when the user navigates the site using the browser’s previous and next arrows both the page and the comments change accordingly? Hope you can help.

Thank you.

Hi I'm glad it's working now. Either method of replying is fine, they're both essentially the same, it's just one uses ajax and has fewer posting features. The problem is I can only spend so much time helping people, particularly if you don't have a licence. In any case I'm sorry I'm not entirely sure how you would change that as I haven't worked much with the functionality of previous/forward buttons. It's the kind of thing you'd get a good response from on a developer community site such as stackoverflow or similar though.

Have you completed the interview?

I will purchase a licence as soon as I get everything to work normally. I understand your point. You have been very helpful, thanks. But as it stands right now, the iframe-related code seems to have stolen all the navigating functions of the parent page for itself, the result being that when navigating back and forth only the iframe changes but the parent window, its href and the article itself don't change accordingly. I have searched the web for a solution to this, but so far to no avail. Unless I can find a way to fix this, or work out some sort of compensation in my code, this comments systems, unfortunately, is still virtually unusable on my site. Too bad, I guess, it got so close to completion.

QUESTION/SUGGESTION: would there not be a way to accomplish the same (i.e., dynamic loading/updating of the comments) using the php integration instead of the iframe integration? That would at least eliminate issues related to the iframe, as I believe this particular one is all about.

ALSO: if you are willing to look into this matter but first need me to purchase a licence, no problem, I will gladly purchase one right away.
Again, thanks for all you valuable help.

Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
06-Aug-2021, 06:50 PM
Last Post by clixcity
29-Jul-2020, 07:56 PM
Last Post by Steven
09-Jul-2018, 08:40 PM
Last Post by vkp
22-May-2017, 04:28 AM
Last Post by tashi
23-Jul-2015, 07:45 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)