Yii Framework Forum: [SOLVED] Widget mostra il sorgente tra gli asset - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Widget mostra il sorgente tra gli asset Rate Topic: -----

#1 User is offline   Customsoft 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 18-May 11
  • Location:Arzignano

Posted 11 July 2011 - 08:32 AM

Ho creato il mio primo widget
Tutto abbastanza bene tranne un fatto. viene messo tra gli assets anche il sorgente in php

Io ho:
/public_html/assets/a57a8820/simpleJCarouselLite.php
/public_html/assets/a57a8820/lib/jCarouselLite.js
/public_html/assets/a57a8820/lib/jquery.easing.js
/public_html/assets/a57a8820/lib/jquery.mousewheel.js

quando invece dovrei avere solo i file JS tra gli assets

I sorgenti sono in:
/public_html/protected/extensions/simpleJCarouselLite/simpleJCarouselLite.php
/public_html/protected/extensions/simpleJCarouselLite/lib/jCarouselLite.js
/public_html/protected/extensions/simpleJCarouselLite/lib/jquery.easing.js
/public_html/protected/extensions/simpleJCarouselLite/lib/jquery.mousewheel.js



La mia view è:
<?php
$this->widget('ext.simpleJCarouselLite.simpleJCarouselLite',array(
  'classDiv'=>'carosello',
  'btnNext'=>'next',
  'btnPrev'=>'prev',
  'mouseWheel'=>'true',
  'circular'=>'false',
  'visible'=>'1',
  'scroll'=>'1',
  'lang'=>'it',
  'theme'=>'default',
  'onClick'=>'',
  'ajaxUrl' => '/p/',
  'onClick'=>'
    var id = $(this).attr("src");
    alert(id);
    $("#footer").hide();
  '
));
?>


mentre il widget:
<?php

/**
 * Description of simpleJCarouselLite
 *
 * @author Marco
 */
class simpleJCarouselLite extends CInputWidget {
  private $baseUrl;
                  
  public $ajaxUrl;
  public $id = 'simpleJCarousel_widget';
  public $classDiv = 'anyClass';
  public $btnNext = ".next";
  public $btnPrev = ".prev";
  public $mouseWheel = true;
  public $circular = false;
  public $visible = 1;
  public $scroll = 1;
  public $lang = 'it';
  public $theme = 'default'; 
  public $onClick;
  

  public function run()
  {
        $clientScript = Yii::app()->getClientScript(); 
        $clientScript->registerCoreScript('jquery');
        $clientScript->registerCoreScript('jquery-ui');
        $dir = dirname(__FILE__);
        $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);
        $clientScript->registerScriptFile($this->baseUrl . '/lib/jCarouselLite.js', CClientScript::POS_HEAD);
        $clientScript->registerScriptFile($this->baseUrl . '/lib/jquery.easing.js', CClientScript::POS_HEAD);
        $clientScript->registerScriptFile($this->baseUrl . '/lib/jquery.mousewheel.js', CClientScript::POS_HEAD);
        $clientScript->registerScript('CaroselloSerie',
'$(function() {
  $(".'.$this->classDiv.'").jCarouselLite({
    btnNext: "'.$this->classDiv.'-'.$this->btnNext.'",
    btnPrev: "'.$this->classDiv.'-'.$this->btnPrev.'",
    mouseWheel: '.$this->mouseWheel.',
    circular: '.$this->circular.',
    visible: '.$this->visible.',
    scroll: '.$this->scroll.'
  });
  $(".'.$this->classDiv.' div ul li img").click(function() {
    '.$this->onClick.'
  });
  
});');

        echo '
<div class="'.$this->classDiv.'">
  <div class="'.$this->classDiv.'-controls">
    <button class="'.$this->classDiv.'-'.$this->btnPrev.'"><<</button>
    <button class="'.$this->classDiv.'-'.$this->btnNext.'">>></button>
  </div>
  <div class="'.$this->classDiv.'-image">
     <ul>
          <!--li><img src="someimage" alt="" width="100" height="100" ></li-->
          '.self::imgSerie().'
      </ul>
  </div>
</div>
';        
  }

  
  private function imgSerie() 
  {
    $sImgSerie = '';
    $objModel = new ArchProdotti();
    $objRecords = $objModel->findAll();
    foreach ($objRecords AS $k => $aRecord)
    {
      $sImgSerie .= '<li><img id="'.$aRecord->Id.'" src="'.IMGS.'/'.$aRecord->Img.'" alt="" width="150" height="100" ></li>'."\n";
    }
    return $sImgSerie;

  }
}

?>


Sorvoliamo su imgSerie che va riscritta. Quel che non capisco è come mai mi metta il file php tra gli assets pubblici :-(

Che passaggio sbaglio?

Grazie
Saluti
Marco (SE&O)
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 11 July 2011 - 09:55 AM

Guarda qua:

 $dir = dirname(__FILE__);
 $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);

Pubblichi tutta la cartella, dovresti fare:

 $dir = dirname(__FILE__). '/lib';
 $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);

1

#3 User is offline   Customsoft 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 18-May 11
  • Location:Arzignano

Posted 11 July 2011 - 10:06 AM

View Postzaccaria, on 11 July 2011 - 09:55 AM, said:

Guarda qua:

 $dir = dirname(__FILE__);
 $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);

Pubblichi tutta la cartella, dovresti fare:

 $dir = dirname(__FILE__). '/lib';
 $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);



Grazie ... il solito bicchier d'acqua ... solo che dopo ore che vedi e rivedi il codice ti passa sotto il naso l'errore! :-)
Saluti
Marco (SE&O)
0

#4 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 13 July 2011 - 02:03 AM

E quando il codice funziona, non hai neanche voglia di correggere una finezza...
0

#5 User is offline   Customsoft 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 18-May 11
  • Location:Arzignano

Posted 13 July 2011 - 03:18 AM

View Postzaccaria, on 13 July 2011 - 02:03 AM, said:

E quando il codice funziona, non hai neanche voglia di correggere una finezza...


Scusa non ho capito :-O
Saluti
Marco (SE&O)
0

#6 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 13 July 2011 - 03:42 AM

Era una battuta, dico che una volta che hai ottenuto il risultato e il widget funziona, non si ha molta voglia di capire perche' ci sono file in piu' pubblicati, si sente forte la voglia di dire:

funziona => non lo toccare!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users