Prestashop 1.6 - 在admin中创建视频部分以管理和显示前端

时间:2015-01-09 04:42:16

标签: php prestashop-1.6

我在localhost中使用prestashop 1.6版。我需要在管理员/后台办公室添加我们自己的视频部分,以便在前端的单独页面中管理和显示这些视频。例如,关于我们以及类似的术语和条件页面。

我已经开发了自己的模块到模块的配置部分。现在我需要添加自己的表单字段,如title,embedcode和submit按钮。我不知道如何使用" helper class"添加我们自己的表单字段。 prestashop。此外,我已阅读文档,但无法得到。你能指导我吗?提前致谢,对不起我的英语。

这是我的代码: videomodule.php:

          <?php 

          if (!defined('_PS_VERSION_'))
            exit;
          class VideoModule extends Module
          {
            public function __construct()
              {
                $this->name = 'videomodule';
                $this->tab = 'video';
                $this->version = 1.0;
                $this->author = 'Dinesh Kumar';
                $this->need_instance = 0;
                $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); 
                $this->bootstrap = true;

                parent::__construct();

                $this->displayName = $this->l('Video Module');
                $this->description = $this->l('It is really an awesome experience');
                $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
            Configuration::updateValue('video', serialize(array(true, true, false)));
                if (!Configuration::get('videomodule'))      
                        $this->warning = $this->l('No name provided');

                //  echo Configuration::get('videoid');
              }
          public function getContent()
          {
              $output = null;

              if (Tools::isSubmit('submit'.$this->name))
              {
                  $my_module_name = strval(Tools::getValue('videomodule'));
                  if (!$my_module_name
                    || empty($my_module_name)
                    || !Validate::isGenericName($my_module_name))
                      $output .= $this->displayError($this->l('Invalid Configuration value'));
                  else
                  {
                      Configuration::updateValue('videomodule', $my_module_name);
                      $output .= $this->displayConfirmation($this->l('Settings updated'));
                  }
              }
              return $output.$this->displayForm();
          }

          public function displayForm()
          {
              // Get default language
              $default_lang = (int)Configuration::get('PS_LANG_DEFAULT');

              // Init Fields form array
              $fields_form[0]['form'] = array(
                  'legend' => array(
                      'title' => $this->l('Settings'),
                  ),
                  'input' => array(
                      array(
                          'type' => 'text',
                          'label' => $this->l('Configuration value'),
                          'name' => 'videomodule',
                          'size' => 20,
                          'required' => true
                      )
                  ),

                  'submit' => array(
                      'title' => $this->l('Save'),
                      'class' => 'button'
                  )
              );



              $helper = new HelperForm();

          // Module, Token and currentIndex
          $helper->module = $this;
          $helper->name_controller = $this->name;
          $helper->token = Tools::getAdminTokenLite('AdminModules');
          $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;

          // Language
          $helper->default_form_language = $default_lang;
          $helper->allow_employee_form_lang = $default_lang;

          // title and Toolbar
          $helper->title = $this->displayName;
          $helper->show_toolbar = true;        // false -> remove toolbar
          $helper->toolbar_scroll = true;      // yes - > Toolbar is always visible on the top of the screen.
          $helper->submit_action = 'submit'.$this->name;
          $helper->toolbar_btn = array(
              'save' =>
              array(
                  'desc' => $this->l('Save'),
                  'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
                  '&token='.Tools::getAdminTokenLite('AdminModules'),
              ),
              'back' => array(
                  'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
                  'desc' => $this->l('Back to list')
             )
          );

          // Load current value
          $helper->fields_value['videomodule'] = Configuration::get('videomodule');

          return $helper->generateForm($fields_form);
          }

            public function install()
            {
              if (Shop::isFeatureActive())
                Shop::setContext(Shop::CONTEXT_ALL);

              if (!parent::install() ||
                !$this->registerHook('leftColumn') ||
                !$this->registerHook('header') ||
                !Configuration::updateValue('videomodule', 'my friend')

              )
                return false;

              return true;
            }


            public function uninstall()
            {
              if (!parent::uninstall() ||
                !Configuration::deleteByName('videomodule')
              )
                return false;

              return true;
            }

            public function hookLeftColumn( $params )
            {
              global $smarty;
              return $this->display(__FILE__,'videomodule.tpl');
            }

          public function hookRightColumn($params)
            {
                return $this->hookLeftColumn($params);
            }


          }

0 个答案:

没有答案