The river is an activity stream containing descriptions of activities. In new elgg there is a plugin called “riverdashboard” , And you can add river for your plugins too.Each river may be added after an activity such as add delete etc .You can use the following function for doing this.
add_to_river($viewname,$actionname,$userguid,$entityguid);
The first parameter $viewname is the name of the view that will display the river item and the next one $actionname is the action and the other two parameters are the guid of the user performing the action, and the guid of the entity being acted on.
Elgg recommends the view location of the river views as follows /river/classname/event, where classname is the class you’re interested in (ElggObject for objects, ElggUser for users, and so on) and event is the event (create, update, delete and so on).
River item information will be passed in an object called $vars['item'], which contains two important parameters $vars['item']->subject_guid that is the user guid and the action guid that is the $vars['item']->object_guid .
I would like to share some basics about plugin development in elgg .
In elgg all the plugins will be in mod directory. You can drop your plugin in this directory.
First you need a name for your plugin.The names of the plugins in an installation must be unique.
you need a ‘start.php’ file for each plugin which to describe the common functions for a plugin.This file can be considered as the core controller of all plugins .The start.php must have an init function which initializes the plugin .
You have to register this function to elgg system and have to make sure the initialisation function is called on initialisation.
The following is a sample if the init functuion is yourplugin_init()
register_elgg_event_handler('init','system',’yourplugin _init');
In common the elgg plugin will have following folders
actions : Commonly all action(normally form actions) files are saved in this folder.
And you can register all the actions involved in a plugin with in its start.php file
The function is as follows .
register_action($action, $public = false, $filename = "", $admin_only = false)
For example
register_action('blog/add',false,$CONFIG->pluginspath . "blog/actions/add.php");
the parameters of the register_action indicates
action : The name of the action (here "blog/add")
second parameter is a Boolean parameter.which indicates whether the action is public or not that is whether this action be accessed by people not logged into the system or not.In above example false indicates that it is not a public action.
Next is filename that is where the action is located here the action is located in blog/actions/add.php , $CONFIG->pluginspath gives the path to plugin s that is the full path to mod directory of your elgg installation .
And if it is required you can register the action as admin action .you have to set the fourth parameter as true for this by default it in false.
Views : In common all html files will be in this folder .You can call these views in the plugin using the function
elgg_view(‘viewname’,$array_of params)
You can override existing views also.The view lodes based on the plugin priority.
You can extend views using the function extend_view('original view ','your view');
The view folder contains a default folder which holds all the views of plugin .For the easiness .For the easiness you can use subfolders in the default folder.
For example if you have a plugin named blog and it have a view called create.php in the path views /defaults/blogs/create.php you can call this view like ‘blogs/create ‘ .That is you can call the view as follows elgg_view(‘blogs/create’)
Language file :
This file contains the language translations for the plugin.
Creating Friendly URLS:
You can create nice URLs for your plugin using page handler function.for doing this you have to define and register a page handler in `start.php`,
function handlerfunction($page) {
switch ($page[0])
{
case 'index':
Your code for the index view
break;
case 'your_view':
include(‘yourview’);
break;
}
}
register_page_handler(handler, 'handler_function’);
in this function the first argument handler is your entity type, the next argument is the your plugin function handling the request which will get passed as an array in `$page` this carries each url segments. You can check for a location and can create the cases corresponding to that.
User settings:
Plugins might have some settings , You can create the view in the file settings.phpand you can retrieve the settings by the following function
get_plugin_setting($name, $plugin_name );
and you can set values using
set_plugin_setting($name, $value, $plugin_name);function
You can create widgets on your plugins .The widget might be in the folder views/default/widgets
The widgets folder may have two files one is view.php that is view of widget and the other is eidt.php that is the page for setting the widget display options like number of items to be displayed etc.
You can initialize the widget in the init function using the following function
add_widget_type('widgettitle',$name_of_widget,$desc_of_widget) .
Elgg is one of the most popular open source social networking platform,which runs on the LAMP(Linux, Apache, MySQL, and PHP)
Elgg offers advanced social networking,user management and administration.And elgg has multiple views that allows for mobile applications and embeddable widgets and the web browser view .Elgg has so many features which makes it as the best cms for social networking sites.It has the features friends ,profiles,avatars, and an editable dashboard with widgets.Elgg installation also provides some optional plugins like blog,file,groups etc by default.All these features(Blogs, profiles, communities, files etc)can be shared among users with access levels(private,public and loggedin) and everything can be cataloged by tags.Since everything in elgg is in the form of plugins, it is very flexible to add your own features in to your elgg site .And it also provides a rich library in its core .
Elgg shared the second best award with drupal , in Open Source Social Networking Content Management System awards 2007. and in 2008 Elgg has been featured as the best opensource networking platform award in InfoWorld's 2008 best of opensource awards.
Now Elgg is very popular and it has been used to power social networks for various institutions and organisations.
Elgg Installation :
Requiremets:
The basic requirements for Elgg is listed belows :
* Apache web server needs to be installed with the following modules,
1)mod_rewrite : This module handles a rule-based rewriting engine to rewrite requested URLs ,This module provides unlimited number of rule conditions ,which allows flexible and powerful URL manipulation mechanism.
2) PHP 5+ with the libraries (GD : dynamic image creation,JavaScript Object Notation for API functionality ,multibyte string support for internationalisation) and also recomends the php modules,SOAP and DOM for some plugins and extra functionality
* For data storage MySQL 5+ is required
Installation process :
You can download thelatest version of Elgg from http://elgg.org. Unzip Elgg and upload the files in to your webserver.
You have to create a data directory to store uploaded files.For the security reasons Elgg suggests that data folder should be at out side of the elgg installation .And must be writable to Elgg.
Create a mysql database and Add a user to the database with all privileges.and access your site through browser .
Elgg will allow you to enter the following settings
dbuser : username for database( with all privileges)
dbpass :dbuser password
dbname :database name
dbhost :host name(generally local host)
dbprefix: the name you would like to prefix Elgg tables(by default it is elgg )
After Entering these settings you need to refresh the page .
Elgg installer will try to create two files automatically for your installation. settings.php, which contains the database settings for your installation and .htaccess file.
If these files can't be automatically generated, Elgg installer will give you these files and you have to save it in correct path (ie engine/settings.php and /.htaccess (in this example elgg is the root folder) )
Incase, this won't work, you have to copy engine/settings.example.php to engine/settings.php , open the file and fill in your database details and Copy /htaccess_dist to /.htaccess .
.If the settings are success elgg will redirect in to a page where you can enter site sdetails and full path to the data directory you have created .then refresh the page
The next page will allow you to enter administrator login details.submit the page .Now you can login using the administrator login.
Introduction to GUI :
In the top toolbar, for admin login you can see an administrator link which allows the site administration.
Through the admin panel admin can manage users(user management),can activate/deactivate plugins(Tolls management).
And each user will have a settings menu in top toolbar formanaging individual account settings .
And the top tool bar has a tools menu which is used for navigation along the site.
Introduction to DB :
The elgg provides a flexible data model .You can see the table schema in the elgg core engine .( engine/schema/mysql.sql).
The tables are automatically generated by the elgg installer on the Database specified by you in the settings .
Main tables :
The dbprefix will be the string which is entred by you in the settings during installation( dbprefix)
dbprefixentities : This is the main Elgg entity table.Elgg defines four basic entity types, ElggSite, ElggUser, elggObject and ElggGroup
dbprefixentity_subtypes : This table contains entity subtype information: For example an elgg object can have subtype blog
dbprefixobjects_entity :This table stores additional information relating to object entities
dbprefixsites_entity :This table stores additional information relating to site entities
dbprefixusers_entity :This table stores additional information relating to user entities
dbprefixgroups_entity :This table stores additional information relating to group entities
dbprefixmetadata : This table containsadditional informations attached to an entity.
dbprefixmetastrings : This table contain the actual string of metadata which is linked to by the metadata and annotations tables
Both tables(metadata&annotation) will have a name_id and a value_id which will be an id from metastring
dbprefixannotations : This table contains annotations (for example comments for discussions/blog is saved as annotations )
dbprefixrelationships :This table defines relationships between two entities.
Be an Elggist ;) good luck :)
Popular Posts
- MYSQL joins
- function to check whether the year given is a leap year or not
- Elgg : The most popular open source social networking platform
- How to create a plugin in elgg.
- some php questions
- creating dynamic elements in HTML using Javascript.
- question regarding socket
- MYSQL UNION
- php question
- php Questions