PHP code example of imponeer / smarty-xo

1. Go to this page and download the library: Download imponeer/smarty-xo 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/ */

    

imponeer / smarty-xo example snippets


$smarty = new \Smarty();
$plugins = [
  new \Imponeer\Smarty\Extensions\XO\XOAppUrlCompiler(
    function (string $url): string { // function that converts url into path
       return $url;
    },
    function (string $url, array $params = []): string { // function that adds params to path
       return $url . '?' . http_build_query($params);
    }
  ),
  new \Imponeer\Smarty\Extensions\XO\XOPageNavFunction(
    function (string $url): string { // function that generates real url
      return $url;
    },
    $strPreviousPage = '<',
    $strNextPage = '>',
    $oldSchoolUrlMode = true
  ),
  new \Imponeer\Smarty\Extensions\XO\XOImgUrlCompiler(
     function (string $imgPath): string { // function that makes psiaudo path into real assets path
        return $imgPath;
     }
  ),
  new \Imponeer\Smarty\Extensions\XO\XOInboxCountFunction(
     function (): ?int { // function that calc unread messages in user inbox 
       return 0;
     }
  )
];
foreach ($plugins as $plugin) {
  if ($plugin instanceof \Imponeer\Contracts\Smarty\Extension\SmartyFunctionInterface) {
    $type = 'function';
  } else {
    $type = 'compiler';
  }
  $smarty->registerPlugin($type, $plugin->getName(), [$plugin, 'execute']);
}