We currently only have module_exists
. If there were respective functions for themes and layouts, then code like this:
function _installer_browser_is_project_enabled($type, $name) {
switch ($type) {
case 'module':
return module_exists($name);
break;
case 'theme':
$themes = list_themes();
return isset($themes[$name]);
break;
case 'layout':
$layout = layout_load($name);
return !empty($layout);
break;
}
return FALSE;
}
...which is actually not working to effectively determine whether a layout is enabled or not (#2336) and the best that I could come up with to correct it is this:
function _installer_browser_is_project_enabled($type, $name) {
switch ($type) {
case 'module':
return module_exists($name);
break;
case 'theme':
$themes = list_themes();
return isset($themes[$name]);
break;
case 'layout':
$excluded_templates = config_get('layout.settings', 'excluded_templates');
return (!empty(layout_get_layout_info($name)) && !in_array($name, $excluded_templates));
break;
}
return FALSE;
}
...would be much simpler:
function _installer_browser_is_project_enabled($type, $name) {
switch ($type) {
case 'module':
return module_exists($name);
break;
case 'theme':
return theme_exists($name);
break;
case 'layout':
return layout_exists($name);
break;
}
return FALSE;
}
And if there was a generic project_exists
function, then we wouldn't need _installer_browser_is_project_enabled()
in the first place.
In fact, I don't think that *_exists
as function names are precise. We should consider separate *_exists
and *_enabled
functions. Especially now that we have Project Installer where we need to distinguish between downloaded vs installed/enabled projects.
PS: this is a sibling issue to #332
Recent comments
Hello, @yorkshirepudding! Thanks a lot, I got it, all sorted out.
My layout template (layout--blog.tpl.php) doesn't work
Hi @Gnome and welcome to Backdrop When I create custom layout templates I put them in /layouts/custom/my_layout Note: you can split modules and layouts between contrib and custom...
My layout template (layout--blog.tpl.php) doesn't work
This post explains how to do this in Drupal 7. In Backdrop, File Entity is already part of core. You will need to download and install module Views Field View. https://drupal.stackexchange...
I Need to Display an Image in a View that was Uploaded to a Webform