wdrożenia PrestaShop Powiększenie zdjęć moduł

przesuwanie w module

  • 6 Odpowiedzi
  • 1663 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

*

Offline sznoorek

  • Tubylec
  • ****
  • 178
  • 4
  • Płeć: Mężczyzna
    • Nimfka - artykuły zoologiczne
  • PrestaShop: 1.4.x
  • Status: Właściciel
przesuwanie w module
« dnia: Marzec 19, 2013, 03:28:10 pm »
Czy jest możliwe aby w ustawieniach modułu (typ banner) w którym można dodać kilka pozycji, można było zmieniać kolejność przesuwając jak to jest przy zmianie pozycji modułów?

*

Offline tyszek

  • Tubylec
  • ****
  • 185
  • 6
  • Płeć: Mężczyzna
    • Drogeria - Perfumeria FROCUS
  • PrestaShop: 1.4.x
  • Status: forum
Odp: przesuwanie w module
« Odpowiedź #1 dnia: Marzec 19, 2013, 05:19:07 pm »
Jeśli moduł sam w sobie nie ma możliwości zmiany kolejnosci w ustawieniach modułu pozostaje przerobić plik tpl od modułu.

*

Offline design4VIP

  • user
  • Mieszkaniec
  • *****
  • 3,866
  • 131
    • design4VIP z innej strony...
  • PrestaShop: PS
  • Status: Programista
Odp: przesuwanie w module
« Odpowiedź #2 dnia: Marzec 19, 2013, 05:54:33 pm »
jezeli chodzi o ustawieni modulu (konfiguracja) to jak najbardziej, tylko musisz tylko zastosowac odpowiednie funkcje jQuery w sekcji function displayForm() pliku .php modulu.

PS.
nie wiem co kolega mial na mysli odsylajac cie do .tpl, no chyba, ze chodzi  o takie "przesuwanie" po stronie front
design4VIP z innej strony...

*

Offline sznoorek

  • Tubylec
  • ****
  • 178
  • 4
  • Płeć: Mężczyzna
    • Nimfka - artykuły zoologiczne
  • PrestaShop: 1.4.x
  • Status: Właściciel
Odp: przesuwanie w module
« Odpowiedź #3 dnia: Marzec 19, 2013, 06:13:21 pm »
Chodzi mi o możliwość zmiany pozycji.
Czyli złapać 2 przesunąć na górę aby była 1.

*

Offline sznoorek

  • Tubylec
  • ****
  • 178
  • 4
  • Płeć: Mężczyzna
    • Nimfka - artykuły zoologiczne
  • PrestaShop: 1.4.x
  • Status: Właściciel
Odp: przesuwanie w module
« Odpowiedź #4 dnia: Marzec 19, 2013, 06:16:31 pm »
Tak wygląda mój plik PHP<?php
class Scrollingtext extends Module
{
        protected 
$_xml;
     function 
__construct()
     {
          
$this->name 'scrollingtext';
        
$this->tab 'front_office_features';
          
$this->version '1.0';
         
parent::__construct();
        
$this->page basename(__FILE__'.php');
         
$this->displayName $this->l('Scrolling text');
         
$this->description $this->l('Block of scrolling text');
        
$this->_xml $this->_getXml();
     }
    function 
install()
    {
        if (!
parent::install() OR !$this->registerHook('top'))
            return 
false;
        return 
true;
    }
    function 
putContent($xml_data$key$field)
    {
        
$field htmlspecialchars($field);
        if (!
$field)
            return 
0;
        return (
"\n".'        <'.$key.'>'.$field.'</'.$key.'>');
    }
     function 
getContent()
     {
        global 
$cookie;
        
/* Languages preliminaries */
        
$defaultLanguage intval(Configuration::get('PS_LANG_DEFAULT'));
        
$languages Language::getLanguages();
        
$iso Language::getIsoById($defaultLanguage);
        
$isoUser Language::getIsoById(intval($cookie->id_lang));
                
          
/* display the module name */
          
$this->_html '<h2>'.$this->displayName.' '.$this->version.'</h2>';
          
/* update the editorial xml */
          
if (isset($_POST['submitUpdate']))
          {
            
// Generate new XML data
               
$newXml '<?xml version=\'1.0\' encoding=\'utf-8\' ?>
'."\n";
            $newXml .= '<links>'."\n";
            $i = 0;
            foreach ($_POST['link'] as $link)
            {
                $newXml .= '    <link>';
                foreach ($link AS $key => $field)
                {
                    if ($line = $this->putContent($newXml, $key, $field))
                        $newXml .= $line;
                }

                $newXml .= "\n".'    </link>'."\n";
                $i++;
            }
            $newXml .= '</links>'."\n";
            /* write it into the editorial xml file */
            if ($fd = @fopen(dirname(__FILE__).'/links.xml', 'w'))
            {
                if (!@fwrite($fd, $newXml))
                    $this->_html .= $this->displayError($this->l('Unable to write to the editor file.'));
                if (!@fclose($fd))
                    $this->_html .= $this->displayError($this->l('Can\'t close the editor file.'));
            }
            else
                $this->_html .= $this->displayError($this->l('Unable to update the editor file.[br /]Please check the editor file\'s writing permissions.'));
          }
        if (Tools::isSubmit('submitUpdate'))
        {
                $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
        }
         /* display the editorial's form */
          $this->_displayForm();
          return $this->_html;
     }
    static private function getXmlFilename()
    {
        return 'links.xml';
    }
    private function _getXml()
    {
        if (file_exists(dirname(__FILE__).'/'.$this->getXmlFilename()))
        {
            if ($xml = @simplexml_load_file(dirname(__FILE__).'/'.$this->getXmlFilename()))
                return $xml;
        }
        return false;
    }
    public function _getFormItem($i, $last)
    {
        global $cookie;
        $this->_xml = $this->_getXml();
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
        $output = '
            <div class="item" id="item'.$i.'">
                <h3>'.$this->l('Item #').($i+1).'</h3>
                <input type="hidden" name="item_'.$i.'_item" value="" />';
        $output .= '
                <label>'.$this->l('Scrolling text').'</label>
                <div class="margin-form" style="padding-left:0">
                    <input type="text" name="link['.$i.'][desc]" size="64" value="'.$this->_xml->link[$i]->desc.'" />
                    <p style="clear: both"></p>
                </div>';
        $output .= '
                <label>'.$this->l('Text URL').'</label>
                <div class="margin-form" style="padding-left:0">
                    <input type="text" name="link['.$i.'][url]" size="64" value="'.$this->_xml->link[$i]->url.'" />
                    <p style="clear: both"></p>
                </div>';
        $output .= '
                <div class="clear pspace"></div>
                '.($i >= 0 ? '<a href="javascript:{}" onclick="removeDiv(\'item'.$i.'\')" style="color:#EA2E30"><img src="'._PS_ADMIN_IMG_.'delete.gif" alt="'.$this->l('delete').'" />'.$this->l('Delete this item').'[/url]' : '').'
            </div>';
        return $output;
    }
     private function _displayForm()
     {
        global $cookie;
        /* Languages preliminaries */
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $languages = Language::getLanguages();
        $iso = Language::getIsoById($defaultLanguage);
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
          /* xml loading */
          $xml = false;
          if (file_exists(dirname(__FILE__).'/links.xml'))
              if (!$xml = @simplexml_load_file(dirname(__FILE__).'/links.xml'))
                  $this->_html .= $this->displayError($this->l('Your links file is empty.'));
                $this->_html .= '
        <script type="text/javascript">
        function removeDiv(id)
        {
            $("#"+id).fadeOut("slow");
            $("#"+id).remove();
        }
        function cloneIt(cloneId) {
            var currentDiv = $(".item:last");
            var id = ($(currentDiv).size()) ? $(currentDiv).attr("id").match(/[0-9]/gi) : -1;
            var nextId = parseInt(id) + 1;
            $.get("'._MODULE_DIR_.$this->name.'/ajax.php?id="+nextId, function(data) {
                $("#items").append(data);
            });
            $("#"+cloneId).remove();
        }
        </script>
        <form method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data">
            <fieldset style="width: 800px;">
                <legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->displayName.'</legend>
                    <div id="items">';
                        $i = 0;
                        foreach ($xml->link as $link)
                        {
                            $last = ($i == (count($xml->link)-1) ? true : false);
                            $this->_html .= $this->_getFormItem($i, $last);
                            $i++;
                        }
                        $this->_html .= '
                </div>
                <a id="clone'.$i.'" href="javascript:cloneIt(\'clone'.$i.'\')" style="color:#488E41"><img src="'._PS_ADMIN_IMG_.'add.gif" alt="'.$this->l('add').'" />'.$this->l('Add a new item').'[/url]';
       
        $this->_html .= '
                <div class="margin-form clear">
                    <div class="clear pspace"></div>
                    <div class="margin-form">
                         <input type="submit" name="submitUpdate" value="'.$this->l('Save').'" class="button" />
                    </div>
                </div>
                   
                </fieldset>
            </form>';
     }
     function hookTop($params)
     {
        global $cookie;
        /* Languages preliminaries */
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $languages = Language::getLanguages();
        $iso = Language::getIsoById($defaultLanguage);
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
          if (file_exists(dirname(__FILE__).'/links.xml'))
              if ($xml = simplexml_load_file(dirname(__FILE__).'/links.xml'))
              {
                   global $cookie, $smarty;
                $smarty->assign(array(
                    'xml' => $xml,
                    'this_path' => $this->_path
                ));
                return $this->display(__FILE__, 'scrollingtext.tpl');
            }
        return false;
     }
}
?>
Co mam dokładnie dodać i gdzie?

*

Offline tyszek

  • Tubylec
  • ****
  • 185
  • 6
  • Płeć: Mężczyzna
    • Drogeria - Perfumeria FROCUS
  • PrestaShop: 1.4.x
  • Status: forum
Odp: przesuwanie w module
« Odpowiedź #5 dnia: Marzec 19, 2013, 06:17:46 pm »

nie wiem co kolega mial na mysli odsylajac cie do .tpl, no chyba, ze chodzi  o takie "przesuwanie" po stronie front

Dokładnie to miałem na myśli :) bo myślałem ze chodzi o zmianę jakiegoś modułu od strony Frontu.

*

Offline design4VIP

  • user
  • Mieszkaniec
  • *****
  • 3,866
  • 131
    • design4VIP z innej strony...
  • PrestaShop: PS
  • Status: Programista
Odp: przesuwanie w module
« Odpowiedź #6 dnia: Marzec 19, 2013, 06:35:27 pm »
Dokładnie to miałem na myśli :) bo myślałem ze chodzi o zmianę jakiegoś modułu od strony Frontu.
tutaj pytanie bylo dosc opisane wprost "ustawieniach modulu"


a co do meritum. raczej jezlei chodzi o czesc od strony obslugi z poziomu panelu to musialbys chyba napiac to od podstaw. w tym module jest zbyt wiele przekierowan miedzy funkcjami wiec troche za duzo by bylo. no ale to nie zmienia faktu, ze bez zastosowania jQuery sie nie obedzie. ale mma dla Ciebie prostsze rozwiazanie. zrob tylko dodatkowe pola tekstowe na wpisanie 1,2,3,4...... i to zapisz w bazie danych a pozniej w .tpl wyswieltaj po tej wartosci ASC
design4VIP z innej strony...