Universeorange.com/Docs/

R3m/framework Using plugins

Edit view in:

/project_dir/Host/<subdomain>/<hostname>/<extension>/Docs/View/Get.tpl

With content:

{$menu = menu.get(request('page'))}
<ul class="menu">
{if(!is.empty($menu) && is.array($menu))}
    {for.each($menu as $nr => $item)}
        /**
         *  Where menu.item.html() returns
         *  <a href="{$item.href}" class="{$item.class}"><li>{$item.title}</li></a>
         */   
        {menu.item.html($item)}

    {/for.each}
{/if}
</ul>
/**
 *  Where page.get() returns
 *  Hello world, this is page {request('page')}
 */
{$page = page.get(request('page'))}
{$page}
  1. Defining $menu as array [].
  2. First we use a custom plugin: menu.get().
  3. Then we use a default plugin: if().
  4. Then we use a default plugin: is.empty().
  5. Then we use a default plugin: is.array().
  6. Then the default plugin: for.each().
  7. Showing the custom plugin: menu.item.html().
  8. Then closing the for.each plugin.
  9. Then closing the if plugin.
  10. Then defining $page as string;
  11. Then a custom plugin: page.get().
  12. Showing: $page.

We could write it even easier:

/**
 *  Where menu.get() shows
 *  <ul class="menu">
 *      <a href="{/page/Welcome/" class="page-welcome"><li>...</li></a>
 *      ...
 *  </ul> 
 */
{menu.get(request('page'))}

/**
 *  Where page.get() shows
 *  Hello world, this is page Welcome
 */
{page.get(request('page'))}
  1. Showing: menu.get().
  2. Then showing: page.get().

Next: add a custom plugin

Last modified: 2021-06-07

© 2021 universeorange.com