helpers in packages
Permalink
I created a package, within this package i want to define a helper class, so i created this helper class in a helpers directory (within the package).
When i call Loader::Helper('<helpername>'), it cannot find the helper class.
What's wrong?
When i call Loader::Helper('<helpername>'), it cannot find the helper class.
What's wrong?
$obj = Loader::helper("helpername", "packagehandle");
Thnx that works....
Next one:
Trying to use the zend Gdata fromework for doing some google stuf within this package...
I dit copy the zend library in place en call for example Loader::library('Zend/Gdata/YouTube', 'packagehandle');
It can find the YouTube library ofcource but it start calling for all the other libraries to load....
Is there a possibility to just make them load.
Next one:
Trying to use the zend Gdata fromework for doing some google stuf within this package...
I dit copy the zend library in place en call for example Loader::library('Zend/Gdata/YouTube', 'packagehandle');
It can find the YouTube library ofcource but it start calling for all the other libraries to load....
Is there a possibility to just make them load.
It's great that my response worked. Please mark it as the answer, then.
I can't really answer your second question, because I have not dug into the Zend framework. Please provide a few more details, such as an example of what libraries are trying to load. Hopefully, someone will be able to give you advice.
I can't really answer your second question, because I have not dug into the Zend framework. Please provide a few more details, such as an example of what libraries are trying to load. Hopefully, someone will be able to give you advice.
It's basically a problem of searching for dependent libraries.
the path is
Zend/Gdata/App/something.php
Zend/Gdata/YouTube/....php
Zend/Gdata/YouTube.php
and a lot more..
When i load Loader::library('Zend/Gdata/YouTube', 'packagehandle');
the YouTube.php does a lot of require_once...
For example Zend/Gdata/App.php but it can't find it because it's looking in the wrong context (core libraries and libraries directory ), not in the libraries directory within the package where i want them to live.
Does this make sense?
the path is
Zend/Gdata/App/something.php
Zend/Gdata/YouTube/....php
Zend/Gdata/YouTube.php
and a lot more..
When i load Loader::library('Zend/Gdata/YouTube', 'packagehandle');
the YouTube.php does a lot of require_once...
For example Zend/Gdata/App.php but it can't find it because it's looking in the wrong context (core libraries and libraries directory ), not in the libraries directory within the package where i want them to live.
Does this make sense?
Yes, that makes sense. require_once uses include_path, if no path is given with the filename. include_path is defined in config/base.php. You might be able to override it in site.php. In any case, you would add the additional directory or directories to include_path that should be searched for libraries.
block->inc($filename)
Includes a file found in the block's directory.
$block->getBlockPath()
Returns a path to where the block type's files are located.
Includes a file found in the block's directory.
$block->getBlockPath()
Returns a path to where the block type's files are located.
I was afraid of that..
Problem is that i want it to be part of an installable package.
So if i have to extend the include_path with the path to <packagehandle>/libraries in de site.php I'm not able to.
Any smart suggestions?
Or.. am i able to let the package install add them to the libraries directory in the root?
Thnx....
Problem is that i want it to be part of an installable package.
So if i have to extend the include_path with the path to <packagehandle>/libraries in de site.php I'm not able to.
Any smart suggestions?
Or.. am i able to let the package install add them to the libraries directory in the root?
Thnx....
Since you are supplying the code with your package, you can do anything you want to "your" code. Edit the require_once() calls and add the full path to the library there. The libraries can stay where they are, and site.php does not need to change.
I just realized that it can't be the full path. That would work on your installation, but it will be different on every system. Try a relative path from the concrete root and see if that works.
hmmm could do so; I don't like to "existing" code, which is not owned by me.
Means trouble with upgrades.
Is there no possibility extending the include_path from code?
Means trouble with upgrades.
Is there no possibility extending the include_path from code?
You could try something like the following. I have not tested it.
set_include_path(get_include_path() . PATH_SEPARATOR . $new_path);
set_include_path(get_include_path() . PATH_SEPARATOR . $new_path);
Doesn't work either. Problem is that if you load parts of zend by adding stuff to your own package it gets mixed up.
It then tries to load Gdata/Validate/Hostname/Com which isn't in the core but validate is..
It should work if you ignore the Loader and simply load all required libraries manually.
It then tries to load Gdata/Validate/Hostname/Com which isn't in the core but validate is..
It should work if you ignore the Loader and simply load all required libraries manually.