本文整理汇总了PHP中FLBuilderModel::apply_node_template方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::apply_node_template方法的具体用法?PHP FLBuilderModel::apply_node_template怎么用?PHP FLBuilderModel::apply_node_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::apply_node_template方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_module_template_settings
/**
* Renders the settings lightbox for when a module template
* is added to a layout.
*
* @since 1.6.3
* @param string $parent_id A column node ID.
* @param string $type The type of module.
* @param int $position The new module position.
* @return array|void An array of layout data or nothing if called via AJAX.
*/
public static function render_module_template_settings($parent_id = null, $type = null, $position = false)
{
$post_data = FLBuilderModel::get_post_data();
$template_id = isset($post_data['template_id']) ? $post_data['template_id'] : $template_id;
$parent_id = isset($post_data['parent_id']) ? $post_data['parent_id'] : $parent_id;
$position = isset($post_data['position']) ? (int) $post_data['position'] : $position;
$module = FLBuilderModel::apply_node_template($template_id, $parent_id, $position);
// Force the global parent id.
FLBuilderModel::update_post_data('parent_id', $module->parent);
// Get the settings html.
ob_start();
self::render_module_settings($module->node, $module->type, $module->parent, true);
$settings = ob_get_clean();
// Build the response.
$response = array('layout' => self::render_layout(true), 'settings' => $settings);
// Echo or return the response.
if (defined('DOING_AJAX')) {
echo json_encode($response);
die;
} else {
return $response;
}
}
示例2: render_new_module
/**
* Renders the layout data for a new module.
*
* @since 1.7
* @param string $parent_id A column node ID.
* @param int $position The new module position.
* @param string $type The type of module.
* @param string $template_id The ID of a module template to render.
* @return array
*/
public static function render_new_module($parent_id, $position = false, $type = null, $template_id = null)
{
// Add a module template?
if ($template_id) {
$module = FLBuilderModel::apply_node_template($template_id, $parent_id, $position);
} else {
$module = FLBuilderModel::add_default_module($parent_id, $type, $position);
}
// Render the new module's settings.
$settings = FLBuilder::render_module_settings($module->node, $module->settings->type, $module->parent, false);
// Maybe render the module's parent for a partial refresh?
if ($module->partial_refresh) {
// Get the new module parent.
$parent = !$parent_id ? null : FLBuilderModel::get_node($parent_id);
// Get the node to render.
if (!$parent) {
$row = FLBuilderModel::get_module_parent('row', $module);
$render_id = $row->node;
} else {
if ($parent->type == 'row') {
$col = FLBuilderModel::get_module_parent('column-group', $module);
$render_id = $col->node;
} else {
$render_id = $module->node;
}
}
} else {
$render_id = null;
}
// Return the response.
return array('layout' => self::render($render_id), 'settings' => $settings['settings']);
}
示例3: apply_node
/**
* Applies a node template that is defined as network-wide.
*
* @since 1.6.3
* @param int $template_id The node template post ID.
* @param string $parent_id The new parent node ID for the template.
* @param int $position The position of the template within the layout.
* @return void
*/
public static function apply_node($template_id = null, $parent_id = null, $position = 0)
{
$site_id = self::get_source_site_id();
$template = new StdClass();
if ($site_id) {
if (is_multisite()) {
switch_to_blog($site_id);
}
$template->data = FLBuilderModel::get_layout_data('published', $template_id);
$template->settings = FLBuilderModel::get_layout_settings('published', $template_id);
$template->type = FLBuilderModel::get_user_template_type($template_id);
$template->global = false;
if (is_multisite()) {
restore_current_blog();
}
return FLBuilderModel::apply_node_template($template_id, $parent_id, $position, $template);
}
return false;
}