2017-08-18 1 views
0

Ich versuche, eine Umschreibung URL für meine Prestashop-Modul zu haben. Ich möchte http://shop.dev/perso/id_customer?token=sdfgh5678terzsPrestashop benutzerdefinierte Route Modul keine Arbeit

so habe ich Moduldatei

rootofps/modules/hfn_front/hfn_front.php

<?php 
if (!defined('_PS_VERSION_')) 
    exit; 

class hfn_front extends Module 
{ 

    public function __construct() 
    { 
     $this->name = 'hfn_front'; 
     $this->tab = 'others'; 
     $this->version = '1.0.0'; 
     $this->author = 'Johan VIVIEN'; 
     $this->need_instance = 0; 
     $this->secure_key = Tools::encrypt($this->name); 
     $this->ps_versions_compliancy = array('min' => '1.6.1', 'max' => _PS_VERSION_); 
     $this->bootstrap = true; 
     $this->ps_versions_compliancy['min'] = '1.5.0.1'; 

     parent::__construct(); 

     $this->displayName = $this->l('HFN Front'); 
     $this->description = $this->l('test d\'un module de front'); 

     $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); 

    } 

    public function install() 
    { 

     if (Shop::isFeatureActive()) 
      Shop::setContext(Shop::CONTEXT_ALL); 

     if (parent::install() && 
      $this->registerHook('ModuleRoutes')) 
      return true; 

     return false; 

    } 

    public function uninstall() 
    { 
     /* Deletes Module */ 
     if (parent::uninstall()) 
      return true; 

     return false; 
    } 


    public function hookModuleRoutes() 
    { 
     return array(
       'hfn_front' => array(
        'controller' => 'perso', 
        'rule' => '{/:controller}{/:id_customer}', 
        'keywords' => array(
         'id_customer' => array('regexp' => '[0-9]+', 'param' => 'id_customer'), 
         'controller' => array('regexp' => '[\w]+', 'param' => 'controller') 
        ), 
        'params' => array(
         'fc' => 'module', 
         'module' => 'hfn_front', 
         'controller' => 'perso' 
        ) 
       ) 

      ); 
    } 
} 

Und mein Frontmodul-Controller

ist roofofps/Module/hfn_front/Controller/vorne/perso.php

<?php 


class hfn_frontPersoModuleFrontController extends ModuleFrontController 
{ 
    public function initContent() 
    { 
     parent::initContent(); 

     $error['error'] = 'no found file'; 

     echo json_encode($error); 

     exit(); 
    } 
} 

Aber ich habe eine 404-Seite auf der Vorderseite, wenn ich gehe http://shop.dev/perso/1?token=sdfgh5678terzs

Danke für Ihre Hilfe

Antwort

1

Ich denke, der Schlüssel für die aray falsch ist. Es sollte 'Modul- {Modulname} - {Controller} sein. Außerdem ist nicht sicher, ob die Regel den Namen des Controllers als Variable akzeptiert. Versuchen Sie:

Verwandte Themen