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
- PHP >= 5.6
- (MODX)EvolutionCMS >= 1.1
- (MODX)EvolutionCMS.libraries.ddTools >= 0.60
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
ddGetChunkis not exist on your site,ddInstallerwill just install it. - If
ddGetChunkis already exist on your site,ddInstallerwill check it version and update it if needed.
Manually
1. Elements → Snippets: Create a new snippet with the following data
- Snippet name:
ddGetChunk. - Description:
<b>2.4</b> Snippet gets the chunk contents by its name. For example, it useful to get chunks inside JS code.. - Category:
Core. - Parse DocBlock:
no. - Snippet code (php): Insert content of the
ddGetChunk_snippet.phpfile from the archive.
2. Elements → Manage Files
- Create a new folder
assets/snippets/ddGetChunk/. - Extract the archive to the folder (except
ddGetChunk_snippet.php).
Parameters description
-
name- Desctription: Chunk name or code via
@CODE:prefix. - Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Required
- Desctription: Chunk name or code via
-
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 JSONstringHjsonObject— as HJSONstringQueryFormatted— as Query string- It can also be set as native PHP object or array (e. g. for calls through
\DDTools\Snippet::runSnippetor$modx->runSnippet):arrayAssociativeobject
- Default value: —
- Desctription:
Additional data has to be passed into the chunk.
-
removeEmptyPlaceholders- Desctription: Placeholders which have not values to be replaced by will be deleted from parsed chunk if the parameter equals 1.
- Valid values:
01
- Default value:
0
-
escapeResultForJS- Desctription: Escaping special chars for JS.
- Valid values:
01
- 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
dd/evolutioncms-snippets-ddgetchunk 适用场景与选型建议
dd/evolutioncms-snippets-ddgetchunk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「modx」 「MODX Evo」 「evo」 「modx evolution」 「evo cms」 「evolutioncms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dd/evolutioncms-snippets-ddgetchunk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dd/evolutioncms-snippets-ddgetchunk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dd/evolutioncms-snippets-ddgetchunk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Evolutionize the way you write Laravel code
Snippet runs necessary snippets with necessary params.
A snippet for sending users' feedback messages to a required email, slack and telegram chats or SMS through sms.ru. It is very useful along with ajax technology.
A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.
Tools for modifying strings.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2020-05-08