Add smarty modifer in_array

This commit is contained in:
markjcrane 2023-05-22 21:50:15 -06:00
parent 3311363c27
commit dbb3e90ace
2 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,7 @@
$this->object->setTemplateDir($this->template_dir);
$this->object->setCompileDir($this->cache_dir);
$this->object->setCacheDir($this->cache_dir);
$this->object->registerPlugin("modifier","in_array", "in_array");
}
if ($this->engine === 'raintpl') {
require_once "resources/templates/engine/raintpl/rain.tpl.class.php";

View File

@ -0,0 +1,23 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty in_array modifier plugin
* Type: modifier
* Name: in_array
* Purpose: Checks if a value exists in an array
*
* @param string $needle
* @param array $haystack
*
* @return boolean
*/
function smarty_modifier_in_array($needle, $haystack)
{
return in_array($needle, $haystack);
}