1

So I have a custom widget with block defined in module's config.xml:

<config>
 <modules>
    (...)
 </modules>

 <global>
    <blocks>
        <gwidgets>
            <class>Phil_Gwidgets_Block</class>
        </gwidgets>
    </blocks>
 (...)
 </global>
</config>

Block's file is under app/code/local/Phil/Gwidgets/Block/Slider.php

I believe this is where the problem starts. I insert the widget into Wysiwyg editor in back-and, refresh the front-end and it doesn't appear. I check system log and there's this error:

Warning: file_exists(): open_basedir restriction in effect. File(/usr/share/php5/Mage/Phil/Gwidgets/Block/Slider.php) is not within the allowed path(s): (/home/www/xyz/:/usr/bin/) in /home/www/xyz/html/app/code/core/Mage/Core/functions.php on line 145

So after setting up logging function in functions.php I've found out that these are the directories where autoloader attempts to find by block class:

/home/www/xyz/html/app/code/local/Mage/Phil/Gwidgets/Block/Slider.php
/home/www/xyz/html/app/code/community/Mage/Phil/Gwidgets/Block/Slider.php
/home/www/xyz/html/app/code/core/Mage/Phil/Gwidgets/Block/Slider.php
/home/www/xyz/html/lib/Mage/Phil/Gwidgets/Block/Slider.php
./Mage/Phil/Gwidgets/Block/Slider.php
/usr/share/php5/Mage/Phil/Gwidgets/Block/Slider.php

It nearly does it here:

/home/www/xyz/html/app/code/local/Mage/Phil/Gwidgets/Block/Slider.php

It would find it without '/Mage' in the path.

So the question is why Magento looks for Slider.php in ...local/Mage/... rather than ...local/....?

I'd appreciate any advice on how to fix this issue. :)

4
  • stackoverflow.com/questions/22767161/…
    – zhartaunik
    Commented Apr 13, 2015 at 12:27
  • @zhartaunik thanks for the link but I think that my problem has more to do with Magento's way of parsing plugin configuration.
    – Alan
    Commented Apr 13, 2015 at 12:49
  • Show your Slider.php
    – zhartaunik
    Commented Apr 13, 2015 at 12:51
  • @zhartaunik The problem is that Magento can't find Slider.php so I can have anything inside.
    – Alan
    Commented Apr 14, 2015 at 12:06

2 Answers 2

1

This problem appears because your php tries to access /usr/share/php5 directory but server does not allow that. Check permission of /usr/share/php5 directory.

Answering the question why this folder is in 'include_paths' - check your php.ini configuration and virtual host config maybe it is set there. Default value of include_paths is .:/usr/share/php:/usr/share/pear.

1
  • 1
    Thanks Oleksii. You are right. The problem here is that Magento should look for my file in /home/www/xyz/html/app/code/local/Phil/Gwidgets/Block/Slider.php and not /home/www/xyz/html/app/code/local/Mage/Phil/Gwidgets/Block/Slider.php. In such case it wouldn't have to look for it in /usr/share/php5 and the error wouldn't appear. The question is why Magento looks for it in ...local/Mage/... rather than ...local/....
    – Alan
    Commented Apr 14, 2015 at 7:42
0

I've made two changes to my widget.xml file and the problem disappeared:

1) In definition of a widget I've changed type and module name.

<gwidgets_slider type="gwidgets/widget_slider" translate="label description" module="gwidgets">

2) I've extended template tag from:

<template>
 <required>0</required>
 <visible>0</visible>
 <label>Template</label>
 <value>gwidgets/slider.phtml</value>
</template>

to:

<template>
 <required>0</required>
 <visible>0</visible>
 <label>Template</label>
 <type>select</type>
 <value>gwidgets/slider.phtml</value>
 <values>
  <default translate="label">
   <value>gwidgets/slider.phtml</value>
   <label>Slider template</label>
  </default>
 </values>
</template>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.