Hi,
are snippets loaded to backend or is there a way to load it manualy? I get error: Call to undefined function ...
cheers
Hello Ivan,
no they don't.
If you want to use a specific function of a snippet in Backend, you will need to include it into your php-script.
Like
<?php
$my_snippet = WB_PATH.'/modules/my_snippets_directory/include.php';
if(file_exists($my_snippet){
require_once($my_snippet);
}
Kind regards,
Stefek
Cool, but have another problem..
For example if I have this lame function:
function thisFunction($user) {
global $database, $wb;
...
$to_user = $wb->add_slashes($user);
return $to_user;
}
In snippet I have $wb->add_slashes($something); and when I use it in backend I get: Fatal error: Call to a member function add_slashes() on a non-object in ---- line where I use $wb->add_slashes
How can I redeclare snippet to use $admin in backend instead $wb ???
Or is there another way that same function works in FE and BE
cheers
Hello Ivan,
I only have an Idea on how you could make it, but I am sure that there is a better approach to this than mine.
What about writing a second function for the backend instead of using the same in both places (FE/BE)?
Regards,
Stefek
Before including the snippet, try to add this to your code:
global $wb;
if ( ! is_object($wb) ) {
$wb =& $admin;
}
If this doesn't work, instantiate $wb yourself.
if ( ! is_object($wb) ) {
require_once(WB_PATH.'/framework/class.frontend.php');
$wb = new frontend();
}
It works fine in frontend, but backend is the problem.. I use $wb->add_slashes($something); in frontend to sanitize values, but problem appears when I use function in BE.. tbecause then all $wb->SOMETHING needs to be replaced with $admin->SOMETHING
The code I posted should solve this.
whohoo it works :)
thanks BB !!