Hello,
is there a function which returns the current theme icon's url and fallback to return the url of the standard icon when the theme does not support that icon?
In reply to Adam Lucarz
Re: How to get standard icon, when theme icon is not available
by Mauno Korpelainen -
Mouse right click over (missing) icon - Properties tells usually the address, most standard icons are in sub folders of folder pix are in module folders (mod/nameofmodule/...). Copy the missing icons to custom theme folders.
You may always enable smartpix from Administration -> Miscellaneous -> Experimental
or set to theme config.php $THEME->custompix = false;
For missing admin tree icons read http://moodle.org/mod/forum/discuss.php?d=89825
In reply to Mauno Korpelainen
Re: How to get standard icon, when theme icon is not available
by Adam Lucarz -
Thank you for your answer. But I do not have problems with missing icons. I develop some modules for moodle and use for that new icons. My issue is that all themes will do not know my icons. That would not be a problem if there would be a function which fallback to the standard icons in the pix folder. I have written a helper function for me, but I would like to use an existing one because of consistency. My solution is:
static function get_icon_path($url){
global $CFG;
$result = configuration::build_icon_url($CFG->pixpath,$url);
//check if icon exists
if(!file_exists($result)){
$result = configuration::build_icon_url($CFG->wwwroot."/pix",$url);
}
return $result;
}
private static function build_icon_url($path, $url){
$result = $path;
//prefix slash check
if (!ereg('^/',$url)){
$result .= "/";
}
$result .= $url;
return $result;
}
static function get_icon_path($url){
global $CFG;
$result = configuration::build_icon_url($CFG->pixpath,$url);
//check if icon exists
if(!file_exists($result)){
$result = configuration::build_icon_url($CFG->wwwroot."/pix",$url);
}
return $result;
}
private static function build_icon_url($path, $url){
$result = $path;
//prefix slash check
if (!ereg('^/',$url)){
$result .= "/";
}
$result .= $url;
return $result;
}
In reply to Adam Lucarz
Re: How to get standard icon, when theme icon is not available
by Mauno Korpelainen -
Daniele wanted something similar in http://moodle.org/mod/forum/discuss.php?d=93141
I noticed quite many new rows in error log anyway...if icon file systematically did not exist.