# Theme Guide

You can create you own themes and customize standard themes in very simple way.

# Theme structure and files

Xcrud's theme has 5 required files:

  • xcrud_container.php - this file is static container for ajax side of Xcrud. It can be non-styled, but all Xcrud's event are delegated to this container. I not recommend to change something in this file.
  • xcrud_list_view.php - grid rendering.
  • xcrud_detail_view.php - rendering of create/edit/view screen.
  • xcrud.ini - List of class names of core html elements, which cannot be changed in theme files.
  • xcrud.css - theme styles.

All this files will be loaded automatically.

# Global variables in templates

# $mode

Shows current action. It can be list, create, edit, view.

# Standard render methods

NOTE

Some of render methods can accept a html tag parameter. It can be a simple string ('div','h1' etc) or array array('tag'=>'div'). As an array, you can add any other tag html attributes array('tag'=>'a','href'=>'http://example.com').

# csv_button( classname, icon )

Render csv export button

Render print button button

# add_button( classname, icon )

Render Add button button

# render_limitlist( buttons )

Render dropdown list or buttons with available rows per page.

Parameters

  • buttons - (Optional) enable buttons instead of dropdown, default is false.

# render_pagination()

Pagination

Parameters

  • numbers - (Optional) count of pagination buttons, default is 10
  • offsets - (Optional) first and last buttons offsets, default is 2

Search form

# render_button( name, task, mode_after_task, classname, icon, primary_key )

Sender system action button.

# render_benchmark( tag )

Shows benchmark info. Recomended to put it in the end of template.

# render_grid_head( row_tag, item_tag, arrows_array )

Return grid heading. Arrows_array contains arrows for ordered column. Default is array('asc' => '↑ ', 'desc' => '↓ ')

# render_grid_body( row_tag, item_tag )

Main grid rendering

Renders grid footer if available ( eg sum row)

# render_fields_list()

Creates details row, grid and tabs.

Parameters

  • $mode - mode
  • $container - (Optional) defaults to 'table'
  • $row - (Optional) defaults to 'tr'
  • $label - (Optional) defaults to 'td'
  • $field - (Optional) defaults to 'td'
  • $tabs_block - (Optional) defaults to 'div'
  • $tabs_head - (Optional) defaults to 'ul'
  • $tabs_row - (Optional) defaults to 'li'
  • $tabs_link - (Optional) defaults to 'a'
  • $tabs_content - (Optional) defaults to 'div'
  • $tabs_pane - (Optional) defaults to 'div'

# render_table_name( mode, tag, minimized )

Render table heading with table tooltip and toggle arrow. minimized - used only in container file.

# Sending custom variables in template

# set_var( var_name, value )

Set user variable

# get_var( var_name )

Get user variable

# unset_var( var_name )

Unset user variable

INFO

In theme files current instance can be accessed as $this, e.g. $this->get_var('my_var');

# Relocating template files

# load_view( task, file )

This method allows you to replace default view file by your custom by task for current instance.

$xcrud->load_view('create','my_custom_create_form.php'); 

Your custom theme files must be in your theme folder.

# Creating non-standard rendering

# $this->result_list

Array of arrays with full result from database (grid). You can use it to create your own grid rendering.

# $this->result_row

Array with full result form database (create/edit/view).

# $this->fields_output

Array with rendered fields, exept hidden and additional fields. Every element contains:

  • label - field name, generated by xCRUD or defined by label() method
  • name - full field name, used by xCRUD.
  • value - raw value from database
  • field - already rendered form field by xCRUD.

# $this->hidden_fields_output

Array of rendered hidden fields.

Last Updated: 3/11/2021, 5:43:48 PM