creating a new entity type

Last updated by elgg.developer Comments (6)

Hello everyone,

Iv'e searched for a similar topic but couldn't find any.

In my elgg community we are in need for business pages.

I want to create a page entity which will be the main entity in the site.

This entity will have grater value and importence even then the user entity.

I think that modeling the entity as an ElggObject subtype, and saving all of its data as metadata along with all other ElggObjects` metadata will simply be wrong modeling.

The question is wether it is a wrong idea to create a new type rather then a subtype or not?

If it is - why? what will i loose by doing so?

I know it requires creating a new db table and some code replication from existing entities.

If it is doable and likely, id`e be glad to be instructed just how to correctly do the entity creation.

many thanks.

  • From my experience, there are very few cases that are not accounted for by Elgg's model. You will run into a number of bottlenecks trying to implement the new type.

    Perhaps we would be more helpful if you elaborated on the nature of these pages. What are they for? What behaviour you expect to have? How do they interact between each other, with users and other entities?

  • Another note: you can create a new class extending ElggObject, which you can use to completely redesign the class to your liking.

  • the pages are used for content consumption. a user can be a 'friend' or a 'follower' of a page and then get updated about events on the page.

    the page does not belong to a user like a blog or a file.

    by using elgg object i am bound to save my data to the metadata table.

  • Use an ElggObject. This is exactly what they're for. What is your hesitation on using metadata?

  • im afraid it will affect performence when selecting from a huge table.

    in addition - it doesnt seem to be the right architecture. the page is the main entity of the site - it shouldnt derive from elgg object. it should have the same hirarchy as elgg user.

  • there's no real 'right or wrong way..' ;-)
    ... 'friend' or a 'follower' of a page and then get updated about events -- can be done for any entity type.subtype.
    for performance issues - you should research intio the approrioate metrics before getting too worried or afraid about 'a huge table..' mySQL (can) use(s) the B-Tree (multi balanced structure) indexing mechanism and so access for huge databases.." is catered for ! B-Tree is 'mature' enough (since the 1970's.. until now) to be more than robust for any situation.. there's never been any replacement.

    The cost of going a new entity route -- will all be the class/ library code that you will need to write to manage your new entity ;-oO There seemsm to have been no ready-made working 'plugin' design example to easily follow except the  built into the core :- users-entity & groups entitity ;-( You have a choice...;-)