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

How to disable the new comment area but leave comments visible
#1

Hi, I would like to fill through PHP the name and email of the user to integrate commentics fully with my website.
That works:

              <?php
                $cmtx_name = 'some user';
                $cmtx_email = 'some@some.com';
                $cmtx_website = '';
                $cmtx_town = '';
                $cmtx_country = '';
                $cmtx_state = '';
                $cmtx_identifier = '3';
                $cmtx_reference  = 'myref';
                $cmtx_folder     = '/mycomments/';
                require($_SERVER['DOCUMENT_ROOT'] . $cmtx_folder . 'frontend/index.php');
              ?>

I would like also to show the comments without enabling at all a new comment if the user is not logged in my website.

How can i do that in PHP?

Thanks
Luigi
Reply
#2

(08-Oct-2017, 07:34 PM)luigi Wrote:  I would like also to show the comments without enabling at all a new comment if the user is not logged in my website.

So you want to show the form only if the user is logged into your site?

Have you completed the interview?
Reply
#3

Correct: if the user is logged in (with my user authentication system), PHP will provide username. If not, I just want to show comments but don't allow new ones...
Reply
#4

Any idea on how to do that programmatically (=not from control panel)? Thanks
Reply
#5

Yeah I'll try to take a look this evening.

Have you completed the interview?
Reply
#6

STEP ONE

At the top of your integration code add this line:

PHP Code:
<?php 
$is_logged
= false;

So it should look like this:

PHP Code:
<?php
$is_logged
= false;

$cmtx_identifier = '2';
$cmtx_reference  = 'Page Two';
$cmtx_folder     = '/upload/';
require(
$_SERVER['DOCUMENT_ROOT'] . $cmtx_folder . 'frontend/index.php');
?>

Obviously set it to true or false depending if your user is logged in.

STEP TWO

In /upload/frontend/index.php

Above this line:
PHP Code:
<?php 
require_once(CMTX_DIR_SYSTEM . 'startup.php');

Add this:
PHP Code:
<?php 
define
('CMTX_IS_LOGGED', $is_logged);

STEP THREE

In /upload/frontend/controller/main/form.php

After this line:
PHP Code:
<?php 
public function index() {

Add this:
PHP Code:
<?php 
$this
->data['is_logged'] = CMTX_IS_LOGGED;

STEP FOUR

In /upload/frontend/view/default/template/main/form.tpl

Before this line:
Code:
<div id="cmtx_preview"></div>

Add this:
Code:
<?php if ($is_logged) { ?>

STEP FIVE

In same file

After this:
Code:
<?php } else { ?>
    <div class="cmtx_form_disabled"><?php echo $lang_error_form_disabled; ?></div>
<?php } ?>

Add this:
Code:
<?php } else { ?>
    Please login to post a comment
<?php } ?>

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
29-Sep-2021, 11:41 AM
Last Post by Tim
06-Jan-2021, 08:56 PM
Last Post by afoster
02-Aug-2020, 10:40 PM
Last Post by Tim
18-Oct-2019, 11:45 AM
Last Post by Gevill
23-Jul-2019, 01:17 AM
Last Post by Steven
16-Feb-2018, 09:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)