PHPackages                             dd/evolutioncms-snippets-ddif - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dd/evolutioncms-snippets-ddif

ActiveModxevo-snippet

dd/evolutioncms-snippets-ddif
=============================

This snippet compares different values and returns required chunk or string.

2.3.1(2y ago)01PHPPHP &gt;=5.6.0

Since Sep 28Pushed 1y ago2 watchersCompare

[ Source](https://github.com/DivanDesign/EvolutionCMS.snippets.ddIf)[ Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddif)[ Docs](https://code.divandesign.ru/modx/ddif)[ RSS](/packages/dd-evolutioncms-snippets-ddif/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (1)Versions (9)Used By (0)

(MODX)EvolutionCMS.snippets.ddIf
================================

[](#modxevolutioncmssnippetsddif)

This snippet compares different values and returns required chunk or string.

Requires
--------

[](#requires)

- PHP &gt;= 5.6
- [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) &gt;= 1.1
- [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.ru/modx/ddtools) &gt;= 0.60

Installation
------------

[](#installation)

### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)

[](#using-modxevolutioncmslibrariesddinstaller)

Just run the following PHP code in your sources or [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console):

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

//Install (MODX)EvolutionCMS.snippets.ddIf
\DDInstaller::install([
	'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddIf',
	'type' => 'snippet'
]);
```

- If `ddIf` is not exist on your site, `ddInstaller` will just install it.
- If `ddIf` is already exist on your site, `ddInstaller` will check it version and update it if needed.

### Manually

[](#manually)

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

[](#1-elements--snippets-create-a-new-snippet-with-the-following-data)

1. Snippet name: `ddIf`.
2. Description: `2.3.1 This snippet compares different values and returns required chunk or string.`.
3. Category: `Core`.
4. Parse DocBlock: `no`.
5. Snippet code (php): Insert content of the `ddIf_snippet.php` file from the archive.

#### 2. Elements → Manage Files

[](#2-elements--manage-files)

1. Create a new folder `assets/snippets/ddIf/`.
2. Extract the archive to the folder (except `ddIf_snippet.php`).

Parameters description
----------------------

[](#parameters-description)

- `operand1`

    - Desctription: The first operand for comparing.
        An empty unparsed placeholder (like `'[+somePlaceholder+]'`) will be interpretated as empty string (`''`).
    - Valid values: `string`
    - **Required**
- `operand2`

    - Desctription: The second operand for comparing.
    - Valid values: `string`
    - Default value: `''`
- `operator`

    - Desctription: Comparing operator.
        Values are case insensitive (the following names are equal: `'isNumeric'`, `'isnumeric'`, `'ISNUMERIC'`, etc).
    - Valid values:
        - `'=='`
        - `'!='`
        - `'>'`
        - `'
