PHP code example of ajur-media / template

1. Go to this page and download the library: Download ajur-media/template library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ajur-media / template example snippets




$SMARTY = new Smarty();
$SMARTY->setTemplateDir( __DIR__ );
$SMARTY->setCompileDir( __DIR__ . '/cache/');
$SMARTY->setForceCompile(true);

// Global + inner templates

$global = new \AJUR\Template($SMARTY, $_REQUEST);
$global->setTemplate('1.tpl');

$inner = new \AJUR\Template($SMARTY);
$inner->setTemplate("2.tpl");
$inner->assign('value_1', 'FOO');
$inner->assign('value_2', 'BAR');

$global->assign("content", $inner->render());

echo $global->render();

// Global + AR',
]);

$global->setRenderType(\AJUR\Template::CONTENT_TYPE_JSON);

echo $global->render();


{$size|size_format:decimals:separator:separator}

public static function size_format(int $size, int $decimals = 0, string $decimal_separator = '.', string $thousands_separator = ','):string;

{$size|size_format:[3,',','-']}

public static function sf(int $size, array $params):string 
{
    $decimals = $params['decimals'] ?? 3;
    $decimal_separator = $params['decimal_separator'] ?? '.';
    $thousands_separator = $params['thousands_separator'] ?? ',';
    // ...
}

{sum a=11 b=14}

function sum($params)
{
    return ($params['a'] ?? 0) + ($params['b'] ?? 0);
}