public static function InstapageCmsPluginHelper::loadTemplate in Instapage plugin 8.3
Same name and namespace in other branches
- 7.3 core/InstapageCmsPluginHelper.php \InstapageCmsPluginHelper::loadTemplate()
Loads content of a given template and prints it or returns it as a string.
Parameters
string $tmpl Name of the template to load.:
bool $print If set to true, content of the template will be printed to stdio. In other case it will be returned. Default: true.:
Return value
string|void Content of the template as a string or void, if print === true.
Throws
\Exception if template file is not found.
4 calls to InstapageCmsPluginHelper::loadTemplate()
- InstapageCmsPluginDrupal7Connector::loadPluginDashboard in core/
connectors/ InstapageCmsPluginDrupal7Connector.php - Loads the plugin dashboard.
- InstapageCmsPluginDrupal8Connector::loadPluginDashboard in core/
connectors/ InstapageCmsPluginDrupal8Connector.php - Loads the plugin dashboard.
- InstapageCmsPluginHelper::initMessagesSystem in core/
InstapageCmsPluginHelper.php - Loads 'messages' template to initiate a container for plugin system messages.
- InstapageCmsPluginWPConnector::loadPluginDashboard in core/
connectors/ InstapageCmsPluginWPConnector.php - Loads the plugin dashboard.
File
- core/
InstapageCmsPluginHelper.php, line 18
Class
- InstapageCmsPluginHelper
- Helper containing commonly used static functions.
Code
public static function loadTemplate($tmpl, $print = true) {
$templateFile = INSTAPAGE_PLUGIN_PATH . '/views/' . $tmpl . '.php';
if (file_exists($templateFile)) {
if (!$print) {
ob_start();
}
require $templateFile;
if (!$print) {
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
}
else {
throw new Exception(InstapageCmsPluginConnector::lang('Template file (%s) not found', $templateFile));
}
}