本文整理匯總了PHP中ElementHelper::get_tv_element_properties方法的典型用法代碼示例。如果您正苦於以下問題:PHP ElementHelper::get_tv_element_properties方法的具體用法?PHP ElementHelper::get_tv_element_properties怎麽用?PHP ElementHelper::get_tv_element_properties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ElementHelper
的用法示例。
在下文中一共展示了ElementHelper::get_tv_element_properties方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filemtime
$tv_file_contents = file_get_contents($tv_file_path);
$tv_file_mod_time = filemtime($tv_file_path);
$tvs = $tv_file_contents !== '' ? json_decode($tv_file_contents) : array();
$flagged_tvs = array();
// Loop through the template variables in the file
foreach ($tvs as $i => $tv) {
$element = Element::get($modx, 'modTemplateVar', $tv->name);
// If the element is not in the sync
if (!$element_sync->has_element('modTemplateVar', $tv->name)) {
// If the tv doesn't exist
if (!$element) {
// Create the element
$element = Element::create($modx, 'modTemplateVar', $tv->name);
// If the element is created successfully
if ($element) {
$properties = $element_helper->get_tv_element_properties($tv);
// If templates have been specified and permission to pair tvs with templates has been given
if (isset($tv->template_access) && $modx->getOption('elementhelper.tv_access_control', null, false) == true) {
$element_helper->setup_tv_template_access($element->get_property('id'), $tv->template_access);
}
// If a media source has been specified assign it to the TV
if (isset($tv->media_source)) {
$element_helper->setup_tv_media_source($element->get_property('id'), $tv->media_source);
}
// Set the tv properties and then add it to the sync
if ($element->set_properties($properties)) {
$element_sync->add_element('modTemplateVar', $tv->name, $tv_file_mod_time);
}
}
} else {
$modx->log(MODX_LOG_LEVEL_INFO, $log_prefix . 'An element with the name [' . $tv->name . '] already exists. Unable to sync the element.');