Elgg unextend view

Posted on Dec 24, 2011 in News, Tips & Tricks, Tutorials | 0 comments

Just like you can extend Elgg views you can unextend views. The function elgg_unextend_view takes two parameters. The view that was extended and the view that was extending that view.

elgg_unextend_view($view, $view_extension)

When you look at a fresh Elgg installation, you’ll notice the search form on the front page. If your content is meant for logged in users it does not make sence to display a search form when not logged in. So let’s remove the form from the front page. Find your plugin “myplugin” and add this snippet to your init function in start.php,

if (!elgg_is_logged_in()) {
	elgg_unextend_view('page/elements/header', 'search/header');
}

That’s all you need, the search form is gone. Let’s find another view to remove. Log in and go to your profile. Right next to your profile icon, your latest wire post is displayed. The wire extend your profile page with that view. You can remove it by adding this to myplugin start.php,

elgg_unextend_view('profile/status', 'thewire/profile_status');

This was the fourth tutorial in the series on how to modify elgg through your own plugin, myplugin. We have replaced the Elgg topbar logo, Elgg favicon icon and reviewed elgg extend view and elgg unextend view. You can download a copy of myplugin below, everything is included.

Leave a Comment

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: