2

I have a plugin. In this plugin I did elementtype which extends the user one, but with only one source "clients". I have and New Client button which points to my plugin Plugin_ClientController which looks like this:

class Plugin_ClientController extends UsersController
{

    public function actionIndex( array $variables = array() ) {

       $this->renderTemplate('plugin/client/_index');

    }

    public function renderTemplate($path, array $variables = array()) {

        $path = str_replace('users/', 'plugin/client/', $path);
        parent::renderTemplate($path, $variables);

    }   

}

I don't know if this is the right way to do this, but it seems to work, so like this I can have my one view for Client edit, which is almost the same as users one.

My elementtype is look like this:

class Plugin_ClientElementType extends UserElementType
{

    public function getSources($context = null)
    {
        $sources = array(
            '*' => array(
                'label'    => Craft::t('Clients'),
                'criteria'  => array('groupId' => 1),
                'hasThumbs' => true
            )
        );
        return $sources;
    }

}

So all fine up to here. The problem is in that list: enter image description here

where I list all my clients the url on the title in my case now User1 is pointing to admin/users/[ID] I would like to change it to plugin/client/[ID] if that possible I know that it has to be in the model like this:

class Pluign_ClientModel extends UserModel
{

    protected $elementType = 'Plugin_Client';


    public function getCpEditUrl()
    {
        return UrlHelper::getCpUrl('plugin/client/' . $this->id);
    }


}

But it seems that it's not coming from there. If someone can help me with this would be great. Thank you in advance.

1 Answer 1

3

I found the solution of this was under my nose,

I added this

public function populateElementModel($row){

  $model = Plugin_ClientModel::populateModel($row);
  return $model;

}

In Plugin_ClientElementType and then getCpEditUrl() it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.