Yii Framework Forum: Different Php, Undefined Property - Yii Framework Forum

Jump to content

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

Different Php, Undefined Property Rate Topic: -----

#1 User is offline   Maxxer 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 23-February 11
  • Location:Lecco (LC) - Italy

Posted 22 January 2013 - 04:29 PM

Hi.
I've a module inside my Yii app which uses the following, inside the theme's main.php:
                foreach ($jsFiles as $filename) {
                    Yii::app()->getClientScript()->registerScriptFile(
                        $this->module->assetsUrl.DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR.$filename);
                }   


On my dev pc, with php 5.4.6, works like a charm.
On my production server, with php 5.3.19, the same file results in the following:

Quote

PHP Notice: Trying to get property of non-object in [...]/modules/HotspotLogin/themes/theme1/views/layouts/main.php on line 19

$this->module is undefined.
What could it be?
I'm using Yii 1.1.12, obviously on both hosts.
thanks
YetOpen S.r.l. - Your Open Source Partner
Lecco - Italy
http://www.yetopen.it
0

#2 User is offline   Ziggi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 14-August 12

Posted 22 January 2013 - 05:02 PM

Hmm,

Your code is a bit scary

Why not:

$assetUrl = $this->module->assetsUrl;
$assetUrl .= DIRECTORY_SEPARATOR . 'js' .DIRECTORY_SEPARATOR;

foreach ($jsFiles as $filename) {
   Yii::app()->getClientScript()->registerScriptFile($assetUrl . $filename);
}


Having it organized ths way you can at least test your code and verify where is the error coming from!
0

#3 User is offline   Maxxer 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 86
  • Joined: 23-February 11
  • Location:Lecco (LC) - Italy

Posted 22 January 2013 - 05:47 PM

thanks for the advice.
anyway I solved my problem, it was another bug leading to misloading some other code.
YetOpen S.r.l. - Your Open Source Partner
Lecco - Italy
http://www.yetopen.it
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