yfix.net
  • Home
  • Docs
  • Table
  • Slate
    • bootstrap
    • cyborg
    • slate
  • Overview
  • Install
  • Demos
  • Forms
  • Tables
  • admin
  • allow_deny
  • auto
  • btn
  • btn_active
  • btn_edit
  • btn_func
  • check_box
  • column_options
  • data
  • date
  • footer_add
  • footer_link
  • footer_submit
  • form
  • func
  • htmx
  • icon
  • image
  • input
  • lang
  • link
  • on_post
  • radio_box
  • render
  • rownum
  • select_box
  • stars
  • table
  • text
  • text_padded
  • tpl_row
  • tr
  • user
  • yes_no
  • HTML widgets
  • htmx
  • Misc

link() table()

A column whose cells link somewhere, with the link and the value => text data as arguments.

table()->link($name, $link = '', $data = '', $extra = [])

Options

OptionMeaning
$linkThe URL; %d is the value of this column (or of link_field_name), %<field> any field of the row.
$dataValue => text map shown instead of the value (a category id shows its name).
(text options)Every option of text(): link_field_name, rewrite, link_title, link_trim_width, class...

Example

Name Category
Desk lamp Lighting
Office chair Chairs

Code

$categories = [3 => 'Lighting', 5 => 'Chairs'];
$rows = [
    1 => ['id' => 1, 'name' => 'Desk lamp', 'cat_id' => 3],
    2 => ['id' => 2, 'name' => 'Office chair', 'cat_id' => 5],
];
return table($rows, ['no_pages' => 1])
    ->link('name', '#product-%d', '', ['link_field_name' => 'id'])
    ->link('cat_id', '#category-%d', $categories, ['desc' => 'Category']);

Notes

  • A link the admin may not open (admin_methods, non-super-admin groups) is printed as plain text.
  • The link text is escaped; the URL goes into href as given, so build it from site code.

Bootstrap 3 and 5

Links are mini buttons: btn btn-default btn-xs (Bootstrap 3), btn btn-outline-secondary btn-sm (5); set class for a plain link.

See also: table/text, table/btn, demo:table/filter