Adding show/hide column feature.

components/com_fabrik/views/list/tmpl

You can edit templates (better is to create custom ones) in whatever version :)
 
Well... I have no idea what I'm doing wrong because clearly it isn't working.


Here's the code from "xampp\htdocs\joomla\components\com_fabrik\views\list\tmpl\checkbox3"

from a file default.php and I've set the list template to be the copied template I edited: "checkbox3"

screenshot001sw.png


I've added everything correctly, right?

PHP:
<?php
/**
 * Fabrik List Template: Default
 *
 * @package     Joomla
 * @subpackage  Fabrik
 * @copyright   Copyright (C) 2005 Fabrik. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 */

// No direct access
defined('_JEXEC') or die;

if ($this->tablePicker != '') : ?>
	<div style="text-align:right"><?php echo JText::_('COM_FABRIK_LIST') ?>: <?php echo $this->tablePicker; ?></div>
<?php
endif;
if ($this->getModel()->getParams()->get('show-title', 1)) :?>
	<h1><?php echo $this->table->label;?></h1>
<?php endif;?>

<?php
foreach ($this->headings as $key=>$label) {
	if (substr( $key, 0, strlen('fabrik_')) !== 'fabrik_'){
		?>
		<label><input checked='checked' type='checkbox' value='<?php echo $key?>' class='togglecolumns' /> <?php echo strip_tags($label) ?></label> <br/>
		<?php
	}
 
}?>

<script><!--
window.addEvent('domready', function(){
//check initial state
 
	$$('.togglecolumns').each(function(i){
		if(i.getProperty('checked')){
			$$('.'+i.value).setStyle('display', '');
		}else{
			$$('.'+i.value).setStyle('display', 'none');
		}
	});
 
 
	$$('.togglecolumns').addEvent('click', function(e){
		e = new Event(e);
		var i = $(e.target);
 
		if(i.getProperty('checked')){
			$$('.'+i.value).setStyle('display', '');
 
		}else{
			$$('.'+i.value).setStyle('display', 'none');
 
		}
	});
});
 
--></script>

<?php echo $this->table->intro;?>
<form class="fabrikForm" action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikList">

<?php echo $this->loadTemplate('buttons');
if ($this->showFilters) :
	echo $this->loadTemplate('filter');
endif;

/*
 * For some really ODD reason loading the headings template inside the group
* template causes an error as $this->_path['template'] doesnt cotain the correct
* path to this template - go figure!
*/

$this->headingstmpl = $this->loadTemplate('headings');
$this->showGroup = true;
?>

<div class="fabrikDataContainer">
<?php foreach ($this->pluginBeforeList as $c) :
	echo $c;
endforeach;?>
	<div class="boxflex">
		<table class="fabrikList" id="list_<?php echo $this->table->renderid;?>" >
		 <tfoot>
			<tr class="fabrik___heading">
				<td colspan="<?php echo count($this->headings);?>">
					<?php echo $this->nav;?>
				</td>
			</tr>
		 </tfoot>

			<?php
			echo '<thead>'.$this->headingstmpl.'</thead>';
			if ($this->isGrouped && empty($this->rows)) {
				?>
				<tbody style="<?php echo $this->emptyStyle?>">
				<tr>
				<td class="groupdataMsg" colspan="<?php echo count($this->headings)?>">
				<div class="emptyDataMessage" style="<?php echo $this->emptyStyle?>">
				<?php echo $this->emptyDataMessage; ?>
									</div>
								</td>
							</tr>
						</tbody>
				<?php
			}
		$gCounter = 0;
		foreach ($this->rows as $groupedby => $group) :
			if ($this->isGrouped) :
				$this->groupHeading = $this->grouptemplates[$groupedby] . ' ( ' . count($group) . ' )';
				echo $this->loadTemplate('group_heading');
			endif; ?>
			<tbody class="fabrik_groupdata">
			<tr>
				<td class="groupdataMsg" colspan="<?php echo count($this->headings)?>">
					<div class="emptyDataMessage" style="<?php echo $this->emptyStyle?>">
						<?php echo $this->emptyDataMessage; ?>
					</div>
				</td>
			</tr>
<?php
			foreach ($group as $this->_row) :
				echo $this->loadTemplate('row');
		 	endforeach;
		 	?>
		<?php if ($this->hasCalculations) : ?>
				<tr class="fabrik_calculations">
				<?php
				foreach ($this->calculations as $cal) :
					echo "<td>";
					echo array_key_exists($groupedby, $cal->grouped) ? $cal->grouped[$groupedby] : $cal->calc;
					echo  "</td>";
				endforeach;
				?>
				</tr>

			<?php endif;?>
			</tbody>
			<?php
			$gCounter++;
		endforeach;

		$this->showGroup = false;
		for ($x = $gCounter; $x < $this->limitLength; $x ++) :
			$this->groupHeading = 'hidden ' . $x;
			echo $this->loadTemplate('group_heading');
			echo '<tbody class="fabrik_groupdata" style="display:none"></tbody>';
		endfor;
		?>
		</table>
		<?php print_r($this->hiddenFields);?>
	</div>
</div>
</form>
<?php echo $this->table->outro;?>

Thanks for help!
 
It's working with exactly your code in frontend and backend.
Maybe you must clear Joomla and browser cache.
 
Well, thank You! Atleast now I know there's something wrong with my Joomla not with the code.

Could you please post a screenshot of what you're seeing in the front-end section of Joomla?

Thanks in advance.

EDIT:
It works in the back-end but not in the front-end. I wonder why is that?
 
Are you using the list module or a normal list menu item?
What is your exact fabrik version? (maybe you should update from GitHub)
Are you using a standard Joomla template (e.g beez5)?
 
I got it working. I don't get an error anymore. I just had to enable ajaxify for the list module.

Yes. I'm using the fabrik's list module.
Yes. I'm using the standard template. Atomic that is.... I've modified it a bit though...

I have a new problem though... Filtering and searching doesn't work. Whenever I try to filter stuff, I get the loading screen and it just stays there... doesn't display any data.
If I try to search for stuff, it just displays the whole table.

Also, the "Import from CSV" doesn't work. I can select the file and eveything but it doesn't add it to the table.

Any thoughts?
Thanks!
 
Did you try to call the list the "normal" way via menu item (not as fabrik list module)?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top