Filter out activity from the activity tabs based on tags

Hello dear developers of Elgg :)

I came with an unreasonable question.

I want to filter out some images that appear on the Elgg activity tabs based on the tags they have. In this case for example I want all images that has the "tag" apple not to appear on the tabs of All, Mine and Friend's tabs, and I want those images to appear on a 4th tab I created here overriding the content.php:


 $tabs = array(
    'all' => array(
        'text' => elgg_echo('all'),
        'href' => (isset($vars['all_link'])) ? $vars['all_link'] : "$context/all",
        'selected' => ($filter_context == 'all'),
        'priority' => 200,
    'mine' => array(
        'text' => elgg_echo('mine'),
        'href' => (isset($vars['mine_link'])) ? $vars['mine_link'] : "$context/owner/$username",
        'selected' => ($filter_context == 'mine'),
        'priority' => 300,
    'apples' => array(
        'text' => elgg_echo('Apples'),
        'href' => (isset($vars['apples_link'])) ? $vars['apples_link'] : "$context/apples",
        'selected' => ($filter_context == 'apples'),
        'priority' => 500,

So any suggestion on this? I'm new with the platform so I would appreciate if someone could guide me into the right path.

Thanks in advance :)

  • aloha! the tag_tools plugin does half of what you want, in that it adds a new tab that only shows content that matches the tags that the user has chosen. you could look at that to get the basis of the code you want. i don't think i have seen a plugin that already matches your requirements here.

  • Ok amazing thanks a lot ura! :)

    Yeah this does half what I want, and as temporal solution I can add a link to the tag query page.

    Now I wonder how can I configure this system to work with the activity tabs so it displays in the format of the activity river, and also how I can change the activity query to remove images based on their tags : (

  • ura welcome!

    to do that will require you to over-ride the pages that currently output the data for the relevant tabs on the activity page. i think the specific files to change will be different depending on which version of elgg you are using. in 1.12.x you would need to unregister the existing page handler for the activity pages and add your own one to point the server to your new custom php files for each of the tabs. in 2.x i think the pages are now views, so you could just over-ride them as you would over-ride any other view, without the need to add a plugin handler hook.

    once your custom code is being used to display the tab content, then you would need to change the database queries (using php and elgg's functions/arrays) to output the data you want. there is a metadata query that takes an operator of '<>' which would allow you to exclude items that have a specific tag attached to them.

  • Take a look at my TagUtil class. I see it's a lacking a way to exclude a particular tag, but you might be able to figure it out based on the 3 filtering methods there.

  • Hmm ok I think I found where to do that thanks ura :)

    And Steve your class looks amazing, and with small modifications I'm sure that it can make what I want to =)

    However...where do I have to implement it?

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking