please keep in mind i just copied the code as it exists in Elgg to different view, so I didn't make changes to it