Thank you for the screen shot - it shows that you were working on a different page than I was expecting. Your plugin worked perfectly; it was my request that was flawed.
I had hoped to change the example.com/groups/profile/100/test-group page, which currently displays the following:
I don't like that the "Add discussion topic" moves down with every new topic, thus making it harder for people to start new topics. So, I'd like to either move that link above the topic shown (between the grey bar and the "test topic title"), or maybe add it where "View All" is, or add it as an option on the "Joined" pulldown in the top-right.
Can you point me to those locations?
Just exploring based on the url, I see that the page I'm looking at is not part of /discussions, but rather part of /groups, and the reason that I didn't find "add:object:discussion" here is because it's generated dynamically for different content types (e.g. discussions, pages).
It looks like a lot of the magic comes from groups/views/default/groups/profile/module.php, where the current "Add discussion topic" is part of $footer, the "View All" is part of $menu, and I could add it (not as attractively) to the beginning of $content generated for the section.
Since the pattern seems to be to have my own plugin override the existing behavior, it looks like I should copy module.php into my own plugin and it will override the default one. Since it needs to be loaded later than the original, I assume it's overwriting some registration before the page is rendered. Can you point out where in your plugin code that it identifies itself as replacing a 'discussion' element?
it was my request that was flawed
Of course, this is a groups/module view not discussion.
Copy
mod\groups\views\default\groups\profile\module.php
To same directory of your custom plugin and change this code on this:
if($entity_subtype == 'discussion') {
$add_topic = elgg_view('output/url', [
'text' => elgg_echo('add:object:discussion'),
'href' => elgg_generate_url('add:object:discussion', [
'guid' => $group->guid,
]),
'class' => 'mrm',
]);
}
if (!empty($all_link)) {
$menu = elgg_format_element('span', [
'class' => 'groups-widget-viewall',
], $add_topic . $all_link);
}
This adds your desired link on the module at the top before 'View all'.
Keep in your minds, it was actually for Discussions only not other subtypes.
If you want to use it globally then change my code on:
$add_entity = elgg_view('output/url', [ 'text' => elgg_echo("add:
{$entity_type}:{$entity_subtype}"), 'href' => elgg_generate_url("add:
{$entity_type}:{$entity_subtype}", [ 'guid' => $group->guid, ]), 'class' => 'mrm', ]); if (!empty($all_link)) { $menu = elgg_format_element('span', [ 'class' => 'groups-widget-viewall', ], $add_entity . $all_link); }
Don't forget: Clean the caches after the changes
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.