I have an ElggObject that works pretty much like The Wire. How can I add metadata to this? Basically, I'm looking to add two extra fields to each post. The point is to later try query/filter based on the value of this extra item.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Ivan@ivseverino
Ivan - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Ivan@ivseverino
Ivan - 0 likes
You must log in to post replies.Use create_metadata function
@RvR thanks for the brilliant reply. I have a doubt tough, the method requests a user entity, I should then attach it to the user?, my code goes like this:
Then if I understood correctly, in order to add `somedata`and `moredata` to that object, I should then attach the metadata to ...the user?
If so, I'm a bit confused. How would I get this metadata to display? By getting the userId from getObjectEntity() then trying to get the user? would this be the right way to do it?
Edited
If you want to add metadata to 'object' ($post) then you should create metadata for it:
For getting metadata from $post just use:
If you know the post's GUID only then use elgg_get_metadata_from_id function.
If you want to display posts by metadata then use elgg_get_entities_from_metadata function:
etc
Some examples for creating metadata: 1, 2
More metadata tests also.
And more...
@RvR Brilliant! Thank you!