2015-09-01 2 views
1

J'ai suivi la procédure ci-dessous mais je reçois toujours une erreur d'autorisation refusée. J'utilise opencart 2.xAutorisation Refusée dans la page personnalisée admin opencart

1) Créer un nouveau fichier dans admin/contrôleur/custom/helloworld.php

Votre nom et le nom contrôleur doit être le même dans l'ordre desc:

helloworld.php

<? 

    class ControllerCustomHelloWorld extends Controller{ 
     public function index(){ 
        // VARS 
        $template="custom/hello.tpl"; // .tpl location and file 
      $this->load->model('custom/hello'); 
      $this->template = ''.$template.''; 
      $this->children = array(
       'common/header', 
       'common/footer' 
      );  
      $this->response->setOutput($this->render()); 
     } 
    } 
    ?> 

2) Créer un nouveau fichier dans admin/view/modèle/custom/hello.tpl

Hello.tpl 



<?php echo $header; ?> 
    <div id="content"> 
    <h1>HelloWorld</h1> 
    <?php 
    echo 'I can also run PHP too!'; 
    ?> 
    </div> 
    <?php echo $footer; ?> 

3) Créer un nouveau fichier dans admin/modèle/custom/hello.php

<?php 
    class ModelCustomHello extends Model { 
     public function HellWorld() { 
      $sql = "SELECT x FROM `" . DB_PREFIX . "y`)"; 
      $implode = array(); 
      $query = $this->db->query($sql); 
      return $query->row['total'];  
     }  
    } 

?> 

4) Vous devez ensuite activer le plugin pour éviter les erreurs autorisation: niés

Opencart> Admin> Utilisateurs > Groupes d'utilisateurs> Admin> Modifier Sélectionnez et activez l'autorisation d'accès.

Répondre

3

Voici le chemin ajouter le module helloworld personnalisé dans l'admin

  1. créer admin/controller/custom/helloworld.php

    <?php 
    class ControllerCustomHelloworld extends Controller { 
    
    public function index() { 
    
    $this->load->language('custom/helloworld'); 
    $this->document->setTitle($this->language->get('heading_title')); 
    $this->load->model('custom/helloworld');   
    
    $data['header'] = $this->load->controller('common/header'); 
    $data['column_left'] = $this->load->controller('common/column_left'); 
    $data['footer'] = $this->load->controller('common/footer'); 
    $this->response->setOutput($this->load->view('custom/helloworld.tpl', $data)); 
    
    } 
    } 
    ?> 
    
  2. Créer admin/model/custom/helloworld.php

    <?php 
    class ModelCustomHelloworld extends Model { 
    
    public function helloworldmodel(){ 
    
    } 
    } 
    ?> 
    
  3. créer admin/language/english/custom/helloworld.php

    <?php 
    // Heading 
    $_['heading_title']   = 'Hello world Admin module'; 
    
    ?> 
    
  4. Créer admin/view/template/custom/helloworld.tpl

    <?php echo $header; ?><?php echo $column_left; ?> 
    <h1><?php echo "This is helloworld admin module in opencart 2.x.x.x "; ?></h1>   
    <?php echo $footer; ?> 
    
  5. Aller à system -> users -> user groups -> edit Administrator group. Sélectionnez tout pour access permission et modify permission et enregistrez. enter image description here

Voici le tutoriel http://blog.a2bizz.com/index.php/2015/12/17/create-custom-module-in-opencart-admin/

+1

vraiment utile. travaux –