dd / evolutioncms-snippets-ddcolumnbuilder
Outputs items (e. g. results of ddGetDucuments, ddGetMultipleField, Ditto, etc.) in multiple columns, trying to distribute them evenly.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:modxevo-snippet
Requires
- php: >=5.4.0
- dd/evolutioncms-libraries-ddtools: >=0.60.0
This package is auto-updated.
Last update: 2024-11-06 07:32:41 UTC
README
Outputs items (e. g. results of ddGetDucuments, ddGetMultipleField, Ditto, etc.) in multiple columns, trying to distribute them evenly.
Requires
- PHP >= 5.4
- (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.ddColumnBuilder \DDInstaller::install([ 'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddColumnBuilder', 'type' => 'snippet' ]);
- If
ddColumnBuilder
is not exist on your site,ddInstaller
will just install it. - If
ddColumnBuilder
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
- Snippet name:
ddColumnBuilder
. - Description:
<b>6.1</b> Outputs items (e. g. results of ddGetDucuments, ddGetMultipleField, Ditto, etc.) in multiple columns, trying to distribute them evenly.
. - Category:
Core
. - Parse DocBlock:
no
. - Snippet code (php): Insert content of the
ddColumnBuilder_snippet.php
file from the archive.
2. Elements → Manage Files
- Create a new folder
assets/snippets/ddColumnBuilder/
. - Extract the archive to the folder (except
ddColumnBuilder_snippet.php
).
Parameters description
-
source_items
- Desctription: The source items.
- Valid values:
string
array
- Required
-
source_itemsDelimiter
- Desctription: The source items delimiter (used only if
source_items
is string). - Valid values:
string
- Default value:
'<!--ddColumnBuilder-->'
- Desctription: The source items delimiter (used only if
-
columnsNumber
- Desctription: The number of columns to return.
- Valid values:
integer
- Default value:
1
-
minItemsInColumn
- Desctription: The minimum number of items in one column.
- Valid values:
integer
0
— any
- Default value:
0
-
orderBy
- Desctription: How to sort items?
- Valid values:
'column'
— first fills up the first column, then second, etc ([[1, 2, 3], [4, 5, 6], [7, 8, 9]]
)'row'
— fills up by rows ([[1, 4, 7], [2, 5, 8], [3, 6, 9]]
)
- Default value:
'column'
-
tpls_column
- Desctription: The template for column rendering.
Available placeholders:[+items+]
— items[+columnNumber+]
— number of column
- Valid values:
stringChunkName
string
— use inline templates starting with@CODE:
- Default value:
'@CODE:<div>[+items+]</div>'
- Desctription: The template for column rendering.
-
tpls_columnLast
- Desctription: The template for last column rendering.
Available placeholders:[+items+]
— items[+columnNumber+]
— number of column
- Valid values:
stringChunkName
string
— use inline templates starting with@CODE:
- Default value: =
tpls_column
- Desctription: The template for last column rendering.
-
tpls_outer
- Desctription: Wrapper template.
Available placeholders:[+snippetResult+]
— the snippet result.[+columnsTotal+]
— the actual number of columns[+itemsTotal+]
— the total number of gettingsource_items
- Valid values:
stringChunkName
string
— use inline templates starting with@CODE:
- Default value: — (is not used)
- Desctription: Wrapper template.
-
placeholders
- Desctription:
Additional data has to be passed into the result string.
Nested objects and arrays are supported too:{"someOne": "1", "someTwo": "test" }
=>[+someOne+], [+someTwo+]
.{"some": {"a": "one", "b": "two"} }
=>[+some.a+]
,[+some.b+]
.{"some": ["one", "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::runSnippet
or$modx->runSnippet
):arrayAssociative
object
- Default value: —
- Desctription:
Additional data has to be passed into the result string.
Examples
Run the snippet through \DDTools\Snippet::runSnippet
without DB and eval
//Include (MODX)EvolutionCMS.libraries.ddTools require_once( $modx->getConfig('base_path') . 'assets/libs/ddTools/modx.ddtools.class.php' ); //Run (MODX)EvolutionCMS.snippets.ddColumnBuilder \DDTools\Snippet::runSnippet([ 'name' => 'ddColumnBuilder', 'params' => [ 'source_items' => [ 'Item 1', 'Item 2', 'Item 3', ], 'columnsNumber' => 2 ] ]);