本文整理汇总了PHP中FLBuilderModel::add_default_module方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::add_default_module方法的具体用法?PHP FLBuilderModel::add_default_module怎么用?PHP FLBuilderModel::add_default_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::add_default_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
}
示例2: render_new_module_settings
/**
* Renders the settings lightbox for when a new module
* is added to a layout.
*
* @since 1.0
* @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_new_module_settings($parent_id = null, $type = null, $position = false)
{
$post_data = FLBuilderModel::get_post_data();
$parent_id = isset($post_data['parent_id']) ? $post_data['parent_id'] : $parent_id;
$type = isset($post_data['type']) ? $post_data['type'] : $type;
$position = isset($post_data['position']) ? (int) $post_data['position'] : $position;
$module = FLBuilderModel::add_default_module($parent_id, $type, $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;
}
}