Menu

## Grid extends Template
in package

Grid.php : 18

This class represents a grid system used for layout purposes.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$cols : int
  Number of columns for grid display
$items : array<string|int, mixed>
  Array of data
$num : int
  Variable for line break (Grid)
$src : string
  Name of the currently used template including the folder where the template is stored Starting from DOCUMENT_ROOT, e.g., skin/default/
$skin : string
  Template data
__construct() : mixed
  Constructor
add() : static
  Sets the template variables This function replaces all variables with the provided values in the template immediately
create() : static
  Loads a template It checks the module's file first, if not found, it uses the owner's file
createFromFile() : static
  Loads a template from a file
createFromHTML() : static
  Creates a template from HTML
get() : string
  Returns the directory of the template starting from DOCUMENT_ROOT
getCols() : int
  Get the number of columns in the grid.
hasItem() : bool
  Checks if data has been added to the template
init() : mixed
  Sets the template to be used
insertHTML() : static
  Inserts HTML into the template directly Used to insert HTML between items
isEmpty() : bool
  Checks if the Template file is empty
load() : string
  Loads a template It checks the module's file first, if not found, it uses the owner's file If not found, it returns an empty string
pregReplace() : string
  Executes the preg_replace function
render() : string
  Returns the rendered HTML
setCols() : static
  Set the number of columns in the grid.

### Properties

#### $cols

Grid.php : 23

Number of columns for grid display

`protected int $cols`

The number of columns in the grid

#### $items

Template.php : 32

Array of data

`protected array<string|int, mixed> $items`

#### $num

Template.php : 39

Variable for line break (Grid)

`protected int $num`

#### $src

Template.php : 47

Name of the currently used template including the folder where the template is stored Starting from DOCUMENT_ROOT, e.g., skin/default/

`protected static string $src`

#### $skin

Template.php : 54

Template data

`private string $skin`

### Methods

#### __construct()

Grid.php : 28

Constructor

`public __construct() : mixed`

##### Return values

mixed —

#### add()

Template.php : 64

Sets the template variables This function replaces all variables with the provided values in the template immediately

`public add(array<string|int, mixed> $array) : static`

##### Parameters

$array : array<string|int, mixed>

  An array of variable names and their corresponding values to be replaced in the template Format: array(key1=>val1,key2=>val2)

##### Return values

static —

#### create()

Template.php : 87

Loads a template It checks the module's file first, if not found, it uses the owner's file

`public static create(string $owner, string $module, string $name) : static`

##### Parameters

$owner : string

  The name of the installed module

$module : string

  The name of the module

$name : string

  The name of the template without the file extension

##### Tags

assert

  ('', '', 'FileNotFound')->isEmpty() [==] true

##### Return values

static —

#### createFromFile()

Template.php : 103

Loads a template from a file

`public static createFromFile(string $filename) : static`

##### Parameters

$filename : string

  The filename

##### Tags

assert

  ('FileNotFound') [throws] InvalidArgumentException

throws
  InvalidArgumentException

  If the file is not found

##### Return values

static —

#### createFromHTML()

Template.php : 119

Creates a template from HTML

`public static createFromHTML(string $html) : static`

##### Parameters

$html : string

  The HTML code

##### Return values

static —

#### get()

Template.php : 134

Returns the directory of the template starting from DOCUMENT_ROOT

`public static get() : string`

##### Return values

string —

#### getCols()

Grid.php : 39

Get the number of columns in the grid.

`public getCols() : int`

##### Return values

int —

The number of columns

#### hasItem()

Template.php : 144

Checks if data has been added to the template

`public hasItem() : bool`

##### Return values

bool —

Returns true if the add function has been called before, false otherwise

#### init()

Template.php : 154

Sets the template to be used

`public static init(string $skin) : mixed`

##### Parameters

$skin : string

  The directory of the template starting from DOCUMENT_ROOT without a trailing slash, e.g., skin/default

##### Return values

mixed —

#### insertHTML()

Template.php : 167

Inserts HTML into the template directly Used to insert HTML between items

`public insertHTML(string $html) : static`

##### Parameters

$html : string

  The HTML code

##### Return values

static —

#### isEmpty()

Template.php : 178

Checks if the Template file is empty

`public isEmpty() : bool`

##### Return values

bool —

Returns true if the Template file is empty or not found, false otherwise

#### load()

Template.php : 194

Loads a template It checks the module's file first, if not found, it uses the owner's file If not found, it returns an empty string

`public static load(string $owner, string $module, string $name) : string`

##### Parameters

$owner : string

  The name of the installed module

$module : string

  The name of the registered module

$name : string

  The name of the template without the file extension

##### Return values

string —

#### pregReplace()

Template.php : 219

Executes the preg_replace function

`public static pregReplace(array<string|int, mixed> $patt, array<string|int, mixed> $replace, string $skin) : string`

##### Parameters

$patt : array<string|int, mixed>

  The keys in the template

$replace : array<string|int, mixed>

  The text to replace the keys

$skin : string

  The template

##### Tags

assert

  ('/{TITLE}/', 'Title', '{TITLE}') [==] 'Title'

assert

  ('/{LNG_([\w\s.-'(),%/:&#;]+)}/e', '\Kotchasan\Language::parse(array(1=>"$1"))', '{LNG_Language test}') [==] 'Language test'

##### Return values

string —

#### render()

Template.php : 243

Returns the rendered HTML

`public render() : string`

##### Return values

string —

#### setCols()

Grid.php : 51

Set the number of columns in the grid.

`public setCols(int $cols) : static`

##### Parameters

$cols : int

  The number of columns (must be greater than 0)

##### Return values

static —

This Grid instance for method chaining

## Search results