Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Elgg 1.8 Social Networking

You're reading from   Elgg 1.8 Social Networking Create, customize, and deploy your very own social networking site with Elgg with this book and ebook

Arrow left icon
Product type Paperback
Published in Feb 2012
Publisher Packt
ISBN-13 9781849511308
Length 384 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Cash Costello Cash Costello
Author Profile Icon Cash Costello
Cash Costello
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Elgg 1.8 Social Networking
Credits
Foreword
About the Author
About the Author of 1st edition
About the Reviewers
www.PacktPub.com
Preface
1. Social Networking and Elgg FREE CHAPTER 2. Installing Elgg 3. A Tour of Your First Elgg Site 4. Sharing Content 5. Communities, Collaboration, and Conversation 6. Finding and Using Plugins 7. Creating Your First Plugin 8. Customization through Plugins 9. Theming Elgg 10. Moving to Production Developer's Quick Start Guide Views Catalog Index

Events and hooks


Elgg's events and plugin hooks are an important part of the platform's extensibility. Plugins register functions that are called when an event occurs or a hook is triggered. Through these callback functions, plugins change or extend the functionality of Elgg's engine.

There is overlap between the functionality of events and plugin hooks. Broadly, they can be described as follows:

  • Elgg events notify the registered callback function that something has happened

  • Plugin hooks give callback functions the opportunity to change something that the core has done

The callback functions are called handlers, but do not confuse them with page handlers.

Elgg events

Event handlers are registered with the function elgg_register_event_handler():

elgg_register_event_handler('pagesetup', 'system', 'blog_page_setup');

Multiple handlers can be registered for an event. Each event is identified by two words ('pagesetup' and 'system' in this example). The handler is passed a single object involved in the event. If a blog post has been saved, then it is the blog object. If a comment has been posted, then it is the annotation object. Returning false prevents any other event handlers from running and may stop the core from carrying out its current task.

Plugin hooks

Plugin hook handlers are registered with the function elgg_register_plugin_hook_handler():

elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'twitter_api_public_pages');

Plugin hook handlers are passed a return value and other data associated with the hook. The handler function can return the original return value, a modified version, or something completely different.

Event handlers and plugin hooks do not all operate in the same manner. It is best to check the code and comments where the event or hook is triggered before attempting to use one. Possible events and hooks are found by searching the code for elgg_trigger_event() and elgg_trigger_plugin_hook().

Code location

Functions: /engine/lib/elgglib.php

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image