承接 dd/evolutioncms-snippets-ddgetchunk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dd/evolutioncms-snippets-ddgetchunk

Composer 安装命令:

composer require dd/evolutioncms-snippets-ddgetchunk

包简介

Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.

README 文档

README

Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.

Also it can:

  • Pass additional data to chunk for parsing.
  • Escape special chars for JS.
  • Remove empty placeholders.

Requires

Installation

Using (MODX)EvolutionCMS.libraries.ddInstaller

Just run the following PHP code in your sources or Console:

//Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
	$modx->getConfig('base_path') .
	'assets/libs/ddInstaller/require.php'
);

//Install (MODX)EvolutionCMS.snippets.ddGetChunk
\DDInstaller::install([
	'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetChunk',
	'type' => 'snippet'
]);
  • If ddGetChunk is not exist on your site, ddInstaller will just install it.
  • If ddGetChunk is already exist on your site, ddInstaller will check it version and update it if needed.

Manually

1. Elements → Snippets: Create a new snippet with the following data

  1. Snippet name: ddGetChunk.
  2. Description: <b>2.4</b> Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code..
  3. Category: Core.
  4. Parse DocBlock: no.
  5. Snippet code (php): Insert content of the ddGetChunk_snippet.php file from the archive.

2. Elements → Manage Files

  1. Create a new folder assets/snippets/ddGetChunk/.
  2. Extract the archive to the folder (except ddGetChunk_snippet.php).

Parameters description

  • name

    • Desctription: Chunk name or code via @CODE: prefix.
    • Valid values:
      • stringChunkName
      • string — use inline templates starting with @CODE:
    • Required
  • placeholders

    • Desctription: Additional data has to be passed into the chunk.
      Arrays are supported too: some[a]=one&some[b]=two => [+some.a+], [+some.b+]; some[]=one&some[]=two => [+some.0+], [some.1].
    • Valid values:
      • stringJsonObject — as JSON
      • stringHjsonObject — as HJSON
      • stringQueryFormatted — as Query string
      • It can also be set as native PHP object or array (e. g. for calls through \DDTools\Snippet::runSnippet or $modx->runSnippet):
        • arrayAssociative
        • object
    • Default value: —
  • removeEmptyPlaceholders

    • Desctription: Placeholders which have not values to be replaced by will be deleted from parsed chunk if the parameter equals 1.
    • Valid values:
      • 0
      • 1
    • Default value: 0
  • escapeResultForJS

    • Desctription: Escaping special chars for JS.
    • Valid values:
      • 0
      • 1
    • Default value: 0

Examples

All examples are written using HJSON for the placeholders parameter, but if you want you can use vanilla JSON instead.

Get content of the form into JS code

<script>
	var form = '[[ddGetChunk? &name=`someForm` &escapeResultForJS=`1`]]';
	
	//Insert form to page
	$('body').append(form);
</script>

Get chunk with Ditto and send necessary additional data into it

[[ddGetChunk?
	&name=`someChunk`
	&placeholders=`{
		id: 33
		orderBy: "someTv ASC, pub_date DESC"
	}`
]]

Code of someChunk:

<div class="some">
	<div class="someDesignDiv"></div>
	<div>
		[[Ditto?
			&startID=`[+id+]`
			&orderBy=`[+orderBy+]`
			&tpl=`someChunk_item`
		]]
	</div>
</div>

Run the snippet through \DDTools\Snippet::runSnippet without DB and eval

\DDTools\Snippet::runSnippet([
	'name' => 'ddGetChunk',
	'params' => [
		'name' => 'someChunk'
	]
]);

Links

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固