How can I make all the comment views consistent?

In the river comments under notifications present in the full form. If a comment is really long usually it is norm for a "more" link or atleast a short view. Please see my diagram. Which file can be tweaked to achieve this?image

  • I edited the title to remove words like "urgent" "please" and "help" because they don't add any information to the title.

  • There are quite a number of templates to edit.  If you add the plugin 'developers' to your site and enable it. In the settings area there is a setting called 'Wrap views' if you turn this on, elgg will add comments around every view.

    In the HTML code you will see something like: 

    <!-- developers:begin river/item -->

    .....

    <!-- developers:end river/item -->

    These comments will indicate where the view starts and ends.  Now if you go back to the 'developer' plugin and there is an item 'inspect' click on the 'views' in the drop down. This list will display the registered view and the php file it corsponds to.

    So in the above example the registered view is assoicated with item.php file.

    river/item

    I hope that helps.

  • I thank you for this great clue. I was not aware of this plugin.

  • I found the setting 'Wrap Views' and turned it on. But in the actual web pages I seem not to find <!-- developers:end river/item -->

    Is there any guide explaining it in a little more details?

  • elgg\views\default\river\elements\responses.php - in this file I have made the changes

    $comments = substr($comments, 0, 200);

    but NO success. Any idea what to do ?

     

  • $comments is an array of comment annotations. So, you can't limit the characters shown this way.

    Try

    $comments = elgg_get_annotations($options);

    foreach($comments as $comment) {

        $comment['value'] = elgg_get_excerpt($comment['value']);

    }

    The code in bold is the new one that you have to add below the elgg_get_annotations line that already is in elgg/views/default/river/elements/responses.php.

    When using the "Wrap views" developer setting the name of the views will only get added in the html source code of the pages as comments. You see them only if you open the source code of the page in your browser.

  • I did something like this

    $comments = elgg_get_annotations($options);

    foreach($comments as $comment) {
    $comment['value'] = elgg_get_excerpt($comment['50']);
    }

     Placing actual value 50 on the right side but it makes the comments disappear.

     What may be I am doing wrong?

    Same issue is true for large or long images - https://github.com/Elgg/Elgg/issues/5811

     

  • You may have to flush the cache for elgg.  I find that when I'm doing development I turn off the cache.  There is a setting for this in the developer plugin.

  • Cache has been turned off and already flushed. Its not a problem with cache or anything else but the code itself which I am typing wrong or not doing what I should. I need a little more hand-holding here.

  • The function elgg_get_excerpt you are calling takes two varaibles.

    first value is the string and the second value is the length of the string, try this;

    $comment['value'] = elgg_get_excerpt($comment['value'], 50);