Hey everyone
I would like to know if it is possible to make different object views for the same object.
For example, when on the list page there needs to be a small 1 line view, when in 'full' list page there need to be a bigger object view with more information.
Another question that is kind of related, I want the objects i make with my module 'generic', when i change 1 line in the language file the object needs to be a different object name. But seeing the object view needs to be the name of the object is this possible in any way?
Kind regards
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.
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
- denis d@denis07263548
denis d - 0 likes
You must log in to post replies.Hi Denis,
Yes this is possible, in the object view (eg /views/default/object/<yoursubtype>) there is a variable avaiable which tells you how people would like to view your object.
The variable you're looking for is $vars["full_view"] which can be true or false. If you want to learn how to use this look at the blog plugin (Elgg core) in /mod/blog/views/default/object/blog.php you can learn how to handle different things.
Changing the subtype of you object is very hard, you need to thing ahead a little when chosing a subtype.
What you can do is if you wish to have 1 view for 2 or more subtypes is: in both views of the objects just echo an another view (eg /views/default/object/subtype1 & /views/default/object/subtype2 both call elgg_view("my_plugin/generic_object_view", $vars).
If you are using language keys based on the subtype you can just ask the $vars["entity"] which subtype it is by calling $vars["entity"]->getSubtype()
Hope this helps
Ah yes I see, the full_view is exactly what i need, thank you for this.
I see what you mean with the different views, I'll try things out with the pointers you gave me.
Thank you fro your help!