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?

MissMarvels
 
mose replied on at Permalink Best Answer Reply
mose
$obj = Loader::helper("helpername", "packagehandle");
MissMarvels replied on at Permalink Reply
MissMarvels
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.
mose replied on at Permalink Reply
mose
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.
MissMarvels replied on at Permalink Reply
MissMarvels
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?
mose replied on at Permalink Reply
mose
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.
Mnkras replied on at Permalink Reply
Mnkras
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.
MissMarvels replied on at Permalink Reply
MissMarvels
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....
mose replied on at Permalink Reply
mose
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.
mose replied on at Permalink Reply
mose
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.
MissMarvels replied on at Permalink Reply
MissMarvels
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?
mose replied on at Permalink Reply
mose
You could try something like the following. I have not tested it.

set_include_path(get_include_path() . PATH_SEPARATOR . $new_path);
Remo replied on at Permalink Reply
Remo
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.