1
votes

Can you help with the following problem?

I would like to know how I can insert comments to my module.

I have followed the following steps:

my_new_root_model:

  • Model:
    • DbTable:
      • my_new_models -> extends Engine_Db_Table
    • my_new_model -> extends Core_Model_Item_Abstract
      with functions comments and likes
  • controllers:
    • my_new_model_controller -> extends Core_Controller_Action_Standard
      init:
    public function init()
        {
            // Get subject
            $mynewmodel = null;
            $mynewmodel_id = $this->_getParam('mynewmodel_id', $this->_getParam('id', null));
    
            if(!$mynewmodel_id)
                $mynewmodel = DEFAULT_VALUE;
    
            if( !$this->_helper->requireAuth()->setAuthParams('mynewrootmodel_mynewmodel', null, 'view')->isValid() ) return;
    
            $mynewmodel = Engine_Api::_()->getItem('mynewrootmodel_mynewmodel', $mynewmodel);
            if( $mynewmodel ) {
                Engine_Api::_()->core()->setSubject($mynewmodel);
            }
    
            // Require subject
            if( !$this->_helper->requireSubject()->isValid() ) {
                return;
            }
        }
        
  • views:
    • scripts:
      • mynewmodel:
        • mynewmodel.tpl
         echo $this->action("list", "comment", "core", array("type"=>"mynewrootmodel_mynewmodel", "id"=>$this->mynewmodel->mynewmodel_id)) 
  • In DB:

    engine4_authorization_permissions:

        __level_id  type                        name        value   params__
    __5 mynewrootmodel_mynewmodel view 1 NULL__
    __5 mynewrootmodel_mynewmodel comment 1 NULL__

    engine4_authorization_allow:

        __resource_type             resource_id action  role        role_id     value   params__
    __mynewrootmodel_mynewmodel *id* view everyone 5 1 NULL__
    __mynewrootmodel_mynewmodel *id* comment everyone 5 1 NULL__

    I've got the information of modules as Album, Photo and Video

    This code don't work.

    What steps should I take to insert comments in my module?

    Thanks

    1
    What is exactly your question?bottleboot
    I need to know how I can insert comments to my module, and how I can control the authorization to make the information public, but to comment you have to logindatacas
    That is a lot of questions in one. I think you'll find that people will be able to provide answers faster if you can keep it to one or a more specific question or problem.bottleboot
    ok!, first i only need insert comments into my new Module. What steps should I take to insert comments in my module?. I've tried several things, but does not work.datacas
    I changed the values ​​in the tables engine4_authorization_permissions engine4_authorization_allow and copy/paste the Album module (with minor tweaks) and now I see the comments in my module. :) . But I do not know exactly what it means each column. Does anyone know?datacas

    1 Answers

    0
    votes

    There is a Comment widget under Core category in layout editor. You can put it on any page. To associate comments (and likes and tags) with a model you also need to have comments(), likes() and tags() methods implemented in the model class.