定制 hypejunction/hypeprototyperui 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hypejunction/hypeprototyperui

最新稳定版本:4.5.0

Composer 安装命令:

composer require hypejunction/hypeprototyperui

包简介

Entity prototyping

README 文档

README

Elgg 1.8 Elgg 1.9 Elgg 1.10 Elgg 1.11

User Interface for hypePrototyper

Introduction

The plugin allows developers to present a visual UI for construction forms. This can be useful, when working with volatile entity types that will require admin/user modifications over time.

alt text alt text

Requirements

Even though this plugins runs on 1.8, your theme will need to support jQuery 1.7+.

How to Use

Display the UI

Let's assume you have an action to create/edit new books, e.g. books/save. You may want to differentiate what forms to display, based on what library this book is available in.

Register an action that will take care of storing the form config, e.g. books/prototype/save.

echo elgg_view_form('prototyper/edit', array(
	'action' => 'books/prototype/save',
), array(
	'action' => 'books/save',
	'attributes' => array(
		'type' => 'object',
		'subtype' => 'book',
		'access_id' => ACCESS_PUBLIC,
		'container_guid' => $library_guid,
	),
	'params' => array(
		'layout' => array('main', 'sidebar', 'footer'),
	),
));

Save config

Perhaps the easiest is to store the config as metadata on a library. You can also use plugin settings, annotations or any method that will allow you to retrieve the config to feed into the plugin hook.

In books/prototype/save, save your config:

use hypeJunction\Prototyper\UI\Template;

$container_guid = get_input('container_guid');
$library = get_entity($container_guid);

$prototype = hypePrototyper()->ui->buildPrototypeFromInput();

$library->book_prototype = json_encode($prototype);

Hook into the prototype

elgg_register_plugin_hook_handler('prototype', 'books/save', 'book_form');

function book_form($hook, $type, $return, $params) {

	$book = elgg_extract('entity', $params);
	if (elgg_instanceof($book, 'object', 'book')) {
		$library = $entity->getContainerEntity();
		if ($library->book_prototype) {
			return json_decode($library->book_prototype, true);
		}
	}

	return $return;
}

Display the form

$book = elgg_extract('entity', $vars);
$library = elgg_extract('container', $vars);

$attributes = array(
	'guid' => $book->guid,
	'type' => 'object',
	'subtype' => 'book',
	'container_guid' => $library->guid,
);

$body = hypePrototyper()->form->with($attributes, 'books/save')->viewBody();
$body .= elgg_view('input/submit', array(
	'value' => elgg_echo('save')
));

echo elgg_view('input/form', array(
	'action' => 'action/books/save',
	'body' => $body
));

Handle the form

Now in your action file, all you need to do is use:

$guid = get_input('guid');

$attributes = array(
	'guid' => $guid,
	'type' => 'object',
	'subtype' => 'book',
	'container_guid' => get_input('container_guid'),
);

hypePrototyper()->action->with($attributes, 'books/save')->handle();

统计信息

  • 总下载量: 179
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-07-31