comments section

Let me share this fresh experience of using the comments feature and ask for advice where possible.
I mean comments to the Blog, Pages etc. – generic, somewhat hardcoded functionality.


∗ Permissions to delete comments on one's article
Everyone can delete only their own added comments. The author of an article (blog, page) is not able to delete anyone else's comments on the article. It should be everyone's option to remove whatever undesirable stuff posted on their content, as an obvious feature. Why not possible? One can only report the content – not always suitable, and overloading the administrator. Even if the author changes the settings turning off the comments, the previous comments remain irremovable.
Any possible adjustment? Change some entity's delete–permissions?


∗ The view file for the comments sections – questionable code

less important than the previous matter


I found this when modifying a custom code to make more space between the article and the comments section, otherwise too stuck. Using the ID #comments it was done through a global CSS.

#comments {margin-top: 5rem;}

But then I discovered there were multiple elements with this same ID #comments. Not class but ID. Isn't it even against HTML specification? As a result, any modification to the view file is repeated for every single comment, not just the whole section. In my case, each comment thus had the top margin. And even when adding JavaScript it repeats for all comments.
I've solved it anyway – using the $module_title variable which appears only once.

$module_title = elgg_echo('comments');

Embedding a div element around –

$module_title = '<div style="margin-top: 15rem">'.elgg_echo('comments').'</div>';

But isn't this suspicious?


  • Like Nikolai said, suggestions are always welcome

    About the delete permissions.

    If the content owner could remove all comments you could run into the issue that he/she will remove all comments that go against their views (censorship).
    On the other hand your argument is also valid. Choices ;)

  • But then I discovered there were multiple elements with this same ID #comments. Not class but ID. Isn't it even against HTML specification?

    Yes that would be against HTML specs. But as far as i can tell we only output that view once on a page and thus it wouldn't be a problem.

    Do you have a custom theme or some other plugin that would output that view multiple times? If you have an example of Elgg doing this wrong please let us know on GitHub and will look into this and fix it.

  • Concerning the permissions to delete comments on one's article —

    The option to remove whatever undesirable stuff posted on one's content would be in line with how Facebook functions, for instance.
    Anyway, it seems I will not try to implement it any longer.
    I've tried a solution – using a hooked function with this added content inside:

    $comment_on = get_entity($entity->entity_guid);
    if ($owner->canEdit() || ($comment->owner_guid == $user->guid))
    { return true; }

    It really enabled the owner to delete the comments. However, it also enabled to arbitrarily edit comments made by anyone, which would be a highly undesirable extreme.
    Instead of this, now I would prefer an option to toggle–show/hide the comments, or have a separate page for them. This would, however, require a solution to the replicated ID's.

  • Concerning the multiple elements with this same ID —

    There is no special theme used, the version: 4.2.2. I have modified the source codes quite often, but not in case of the comments – this is a new thing I am coming to. And multilevel comments are enabled – if this can have any influence.


  • multilevel comments add multiple IDs. Oops ;)