/**
* Get the path to a layout from a Plugin
*
* @param string $type Plugin type
* @param string $name Plugin name
* @param string $layout Layout name
*
* @return string Layout path
*
* @since 3.0
*/
public static function getLayoutPath($type, $name, $layout = 'default')
{
$templateObj = Factory::getApplication()->getTemplate(true);
$defaultLayout = $layout;
$template = $templateObj->template;
if (strpos($layout, ':') !== false) {
// Get the template and file name from the string
$temp = explode(':', $layout);
$template = $temp[0] === '_' ? $templateObj->template : $temp[0];
$layout = $temp[1];
$defaultLayout = $temp[1] ?: 'default';
}
// Build the template and base path for the layout
$tPath = JPATH_THEMES . '/' . $template . '/html/plg_' . $type . '_' . $name . '/' . $layout . '.php';
$iPath = JPATH_THEMES . '/' . $templateObj->parent . '/html/plg_' . $type . '_' . $name . '/' . $layout . '.php';
$bPath = JPATH_PLUGINS . '/' . $type . '/' . $name . '/tmpl/' . $defaultLayout . '.php';
$dPath = JPATH_PLUGINS . '/' . $type . '/' . $name . '/tmpl/default.php';
// If the template has a layout override use it
if (is_file($tPath)) {
return $tPath;
}
if (!empty($templateObj->parent) && is_file($iPath)) {
return $iPath;
}
if (is_file($bPath)) {
return $bPath;
}
return $dPath;
}