Hi Denis,
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.
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.
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?
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!
I found a reference on this page: http://docs.elgg.org/wiki/Engine/Views
$full
- Whether to display a full version of the entity. (Defaults to false.)This last parameter is passed to the view as
$vars['full']
. It's up to you what you do with it; the usual behaviour is to only display comments and similar information if this is set to true
But there is no indication where to edit the 'full' en 'partial' views.
if ($vars['full']) {
// display the full view
}
else {
// display list view
}
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.