klox7 VIP
Total posts: 914
02 Dec 2013 09:35

Hey, I would like to place comments and reviews in my records but I'm stuck. This is example of what I need.

How to achieve this? Must I create another section besides my main record section to handle comments? Can I submit comment directly on record page or am I redirected (to comment section)? What to select in Comments provider in Edit type?

Thanks for any help!

Last Modified: 07 May 2015


klox7 VIP
Total posts: 914
13 Jun 2014 18:19

This works

<?php
$parent = ItemsStore::getRecord($item->parent_id);
echo '<a href="'.JRoute::_(Url::record($parent->id)).'">'.$parent->title.'</a>';
?>

klox7 VIP
Total posts: 914
13 Jun 2014 18:35

How would you display upper solution only on pages where there are only reviews (my records) but not inside record with reviews?

Something like if review is inside parent record then don't show code.


Sergey
Total posts: 13,748
16 Jun 2014 00:22

klox7 How would you display upper solution only on pages where there are only reviews (my records) but not inside record with reviews?

You place this code to separate template and set this template for review type only. Or you create parameter in template to show or hide this block. Or you use if.

if($item->parent_id > 0)
{
    $parent = ItemsStore::getRecord($item->parent_id);
    echo '<a href="'.JRoute::_(Url::record($parent->id)).'">'.$parent->title.'</a>';
}

klox7 VIP
Total posts: 914
17 Jun 2014 12:55

I did it with template parameter and it works great. First I added this (under fields_name="tmpl_params") to xml file of Cobalt template:

<fieldset name="custom" label="Custom">
    <field name="parent_item_link" type="radio" class="btn-group" default="1" label="Parent item link">
        <option value="0">CNO</option>
        <option value="1">CYES</option>
    </field>
</fieldset>

Then I added this to php file of same template.

<?php if($params->get('tmpl_params.parent_item_link') == true): ?>

    <?php
    $parent = ItemsStore::getRecord($item->parent_id);
    echo '<a href="'.JRoute::_(Url::record($parent->id)).'">'.$parent->title.'</a>';
    ?>

<?php else: ?>

    <?php echo ''; ?>

<?php endif; ?>

Sergey
Total posts: 13,748
18 Jun 2014 01:24

Awesome! This is actualy how it should be done the right way.


klox7 VIP
Total posts: 914
04 Sep 2014 08:07

I want to add another functionality to Cobalt types as comments.

I have comments and on every comment I would like to add an option "article author" response, like JED has for extension reviews.

And another thing... was maybe added to add vode + - to cobalt type as comments?


Sergey
Total posts: 13,748
04 Sep 2014 23:45

I changed a code a little

<?php if($item->parent_id > 0): ?>
    <?php $parent = ItemsStore::getRecord($item->parent_id); ?>
    <?php if($params->get('tmpl_params.parent_item_link') == true): ?>
        <?php echo '<a href="'.JRoute::_(Url::record($parent->id)).'">'.$parent->title.'</a>'; ?>
    <?php else: ?>
        <?php echo $parent->title; ?>
    <?php endif; ?>
<?php endif; ?>

klox7 I have comments and on every comment I would like to add an option "article author" response, like JED has for extension reviews.

This is impossible to do with cobal type as comment. You can add mutton but it will not open form, but simple open article wheer user will find comment form.

klox7 And another thing... was maybe added to add vode + - to cobalt type as comments?

This already exists in standard comemnts. I am not sure how you can add it to cobalt type as comemnt. You will have to create your own DB table.


klox7 VIP
Total posts: 914
05 Sep 2014 07:07

Sergey This is impossible to do with cobal type as comment.

Can't I somehow add "Cobalt types as comments" to "Cobalt types as comments", limit it somehow with php that only article author can comment it and display "reply" only to article author and when logged in?

Something like:

-record
--cobalt types as comments (record reviews for registered users)
---cobalt types as comments (review response for record article authors)

Sergey This already exists in standard comemnts.

Yes, but I need different fields when adding review, not just comment. Will new field be possible solution?


Sergey
Total posts: 13,748
08 Sep 2014 00:56

klox7 Can't I somehow add "Cobalt types as comments" to "Cobalt types as comments"

I think yes. You can set comment ype as comment for review type. And you can configure who can add comments too.

klox7 Yes, but I need different fields when adding review, not just comment. Will new field be possible solution?

If done right, yes.


klox7 VIP
Total posts: 914
08 Sep 2014 19:15

Sergey I think yes. You can set comment ype as comment for review type. And you can configure who can add comments too.

But how to get relation record (author)- comment (author). You can set Article author can comment but that means that review author can comment his reviews? How to skip one level?

Record (author) - review (user) - reply (record author). How to say that record author can reply? :)

I have another question regarding reviews. I have this code:

<?php $rating = CobaltApi::renderRating(13, 8, ''); ?>
<?php if($params->get('tmpl_core.item_rating')):?>
    <div class="pull-right">Total rating: 
            <?php if($rating['total']/10 <= 5):?>
            <div class="content_rating btn btn-danger btn-small" rel="tooltip" data-original-title="Rating">
                <?php echo round($rating['total']/10, 1);?>
            </div>
            <?php elseif($rating['total']/10 < 8):?>
            <div class="content_rating btn btn-warning btn-small" rel="tooltip" data-original-title="Rating">
                <?php echo round($rating['total']/10, 1);?>
            </div>
            <?php else:?>
            <div class="content_rating btn btn-success btn-small" rel="tooltip" data-original-title="Rating">
                <?php echo round($rating['total']/10, 1);?>
            </div>
            <?php endif;?>
        out of <?php echo $rating['num']; ?> votes!
    </div>
<?php endif;?>

Somehow <?php echo $rating['num']; ?> doesn't display number of votes. Is something wrong here? It used to work. Is there maybe any configuration parameter that can be in conflict? I'm using multiple ratings.

Also <?php echo round($item->votes_result/10, 1);?> doesn't work.

Have no clue...

Regards


Sergey
Total posts: 13,748
09 Sep 2014 01:04

klox7 Record (author) - review (user) - reply (record author). How to say that record author can reply? :)

Ooh! That is what you meant. Unfortunately it is not possible.

klox7 I have another question regarding reviews.

Look into record DB and see what is votes column there.


klox7 VIP
Total posts: 914
09 Sep 2014 09:08

votes and votes_results are 0 in review records. But there is multirating column populated.

Sergey

Record (author) - review (user) - reply (record author). How to say that record author can reply? :)

Ooh! That is what you meant. Unfortunately it is not possible.

What about something with custom php. If I add another type 'Review response' and I want to display it only for main record owner.


Sergey
Total posts: 13,748
11 Sep 2014 02:10

What is type ID 13 and section 8?


klox7 VIP
Total posts: 914
11 Sep 2014 06:00

Sergey What is type ID 13 and section 8?

It is type and section of comments.


Sergey
Total posts: 13,748
11 Sep 2014 14:34

If you run in DB

SELECT r.title, r.votes, r.votes_result FROM #__js_res_record AS r WHERE r.type_id = 13 AND r.section_id = 8

What will you get?


klox7 VIP
Total posts: 914
11 Sep 2014 18:07

I get reviews titles which are OK

and votes and votes_results with 0


Sergey
Total posts: 13,748
12 Sep 2014 08:42

Then the problem is that votes was not saved. Your votes only for article authors?


klox7 VIP
Total posts: 914
25 Sep 2014 13:33

klox7 I have comments and on every comment I would like to add an option "article author" response, like JED has for extension reviews.

I'm back on this because it has to be a way. You mentioned:

Sergey This is impossible to do with cobal type as comment. You can add mutton but it will not open form, but simple open article wheer user will find comment form.

Now I want to simply add a button in reviews list visible only if user is record author. When user clicks on this button it will redirect him to article with "built in comments" and he will be able to submit only one comment.

Is this OK to do? What is php for record author? $target?


Sergey
Total posts: 13,748
26 Sep 2014 03:03

There is new parameter in this comment adapter that allow only authors of the parent record to submit reviews/comments. And there is limit parameter. Only one is also possible.


klox7 VIP
Total posts: 914
26 Sep 2014 08:04

I don't see this parameters in "built in comments".

Powered by Cobalt