Knowledge Base

How to do custom styling for just some tablerenders?

How to find ID (mode) for using in special styling in tablerender() function
on Monday 17 December 2018
comments: 0
Normally you have layout with
If xxx doesn't exist, it will use default setting.

But sometimes you need to use specific styling. You can use $id (or $mode in old themes) for this. There is example in boostrap3 theme.

But how to find what ID to use?

Just add this code in your tablerender() function. Example is in bootstrap3 theme, not look at _blank theme, it's outdated now.

Parameters for tablerender() 
 * @param string $caption
 * @param string $text
 * @param string $id : id of the current render
 * @param array $info : current style and other menu data. 

echo "<!-- tablestyle: style=".$style." id=".$id." -->\n\n";

This way you can see in code what ID is used and style your output according it.
For example:

if($id == 'wmessage')
		$style = '';	

Custom plugin:
$ns->tablerender("My Caption", $text, $myid);

Custom page template:
$PAGE_TEMPLATE['gaia-project']['tableRender'] = 'gaia-project';

There is $info for passing some data to tablerender(), but it's not used too often. It was added as new feature during developing new theme for Not clear how this works.

Example in tablerender() for using page title for pages:
if(!empty($info['title']))  // see $ns->setContent();
	$lead = $info['title'];

Example from LandingZero theme:
if($style === 'menu' && !empty($info['footer']) && !empty($info['text']))
		$style = 'menu-footer';