Render

This class provides methods for rendering views, layouts, components, blocks, and managing assets (CSS, JS).

asset()

function asset($assetType, $file, $options = [])
  • $assetType- 'css' or 'js'

  • $file- File name (relative path from the Assets directory in the view)

  • $options- Options array including:

    • 'area': (default 'frontend')

      • 'location': (default 'head' or 'footer')

Example:

<?php
Render::asset('css', 'styles.css', ['area' => 'frontend', 'location' => 'head']);
Render::asset('js', 'main.js', ['area' => 'frontend', 'location' => 'footer']);

// Make sure CSS and JS files are contained in Views/Fronted/Assets/ folder

renderAsset()

function renderAsset($location = 'head', $area = 'frontend')
  • $location- 'head' or 'footer'

  • $area - 'frontend' or 'backend'

  • return - Resulting HTML.

Example:

render()

  • $layout - Name of the layout to load (e.g., 'layout' or 'layout2')

  • $view - Name of the view to load (e.g., 'home/home')

  • $data- Data to pass to the view

  • return - The buffered output as a string.

Example:

html()

  • $layout - Name of the layout to load (e.g., 'layout' or 'layout2')

  • $data- Data to pass to the view

  • return - The buffered output as a string.

Example:

component()

  • $component- Name of the component to render (e.g., 'header', 'footer')

  • $data- Data to pass to the component

  • return - The buffered output as a string.

Example:

block()

  • $blockName- Name of the Block, can be capitalized or lowercase

  • $data- Additional props parameters of the Block, if not provided, Default will be used

  • return - The block instance.

Example:

getblock()

  • $blockName- Name of the Block, can be capitalized or lowercase

  • return - The block instance or null if the class does not exist.

Example:

Last updated

Was this helpful?