Extending ElggGroup

I am writing a plugin for school project to create special type of group. I extended the ElggGroup with a new class let's say Committee. I have trouble listing the objects of type Committee. The committee objects when listed the url still points to them being as 'group' object. When I tried to edit these objects it goes to default 'group' edit page rather than my newly created page.

 

The objects listed show up with trailing brackets '( )' and hovering over them shows the message "

This entity cannot be displayed correctly. This may be because it requires support provided by a plugin that is no longer installed."

Help is greatly appreciated

Animesh
  • I had the same problem when I tried to list objects that extend ElggGroup. I also running Elgg 1.7.1. 

  • the group plugin is a little difficult to work with for extending with new features or cloning. some months ago for one my clients - i did create a new clone plugin based on groups, which would co-exist with the standard groups and the two would not step on each others toes.. pm me if wanna see a demo.

  • The problem seems to ben in file elgglib.php in function elgg_view_entity.

    This code load de group default view:

    ...

    // if this entity has a view defined, use it

    $view = $entity->view;

    if (is_string($view)) {

    return elgg_view($view,

    array('entity' => $entity, 'full' => $full),

    $bypass,

    $debug);

    }

    $entity_type = $entity->getType();

    $subtype = $entity->getSubtype();

    if (empty($subtype)) {

    $subtype = $entity_type;

    }

    $contents = '';

    if (elgg_view_exists("{$entity_type}/{$subtype}")) {

    $contents = elgg_view("{$entity_type}/{$subtype}", array(

    'entity' => $entity,

    'full' => $full

    ), $bypass, $debug);

    }

    if (empty($contents)) {

    $contents = elgg_view("{$entity_type}/default",array(

    'entity' => $entity,

    'full' => $full

    ), $bypass, $debug);

    }

    ...

  • My solution is:

    Suppose:

    class that extends elgggroup: ElggTeste

    type: group

    subtype: elggteste

    I created a view group/elggteste with the same content of the view group/group. This way the view created is selected in if (elgg_view_exists("{$entity_type}/{$subtype}")).

    Does anyone have a better solution?

  • this sounds like like a lot of core code re-working - i simply created a couple of modules filtermentorspace.php and filtergroups.php which takes care of conflicts without any core hacks ;-)

  • Leo  I am already doing what you have suggested copying over the content of the view group/group into group/committee but in the content I replaced 'group' with my extension 'committee' like the snippet below

    /* replacing 'group' with 'committee'

        if ($vars['full']) {
            echo elgg_view("committee/committeeprofile",$vars);
        } else {
            if (get_input('search_viewtype') == "gallery") {
                echo elgg_view('committee/committeegallery',$vars);                
            } else {
                echo elgg_view("committee/committeelisting",$vars);
            }
        }

     

    I will try with the original content

  • Dhrup

    Would it be possible for you to post your solution. Appreciate it.

  • Leo

    In your setup when you list your ElggTeste objects does the 'url' point to 'http://localhost/pg/groups/$objectId/$objectname/'. In my setup that's how they show up. I would want the url to be more like

    ''http://localhost/pg/elggteste/$objectId/$objectname/' so that they can be routed to the view handling elggteste not group

This discussion is closed.

This discussion is closed and is not accepting new comments.