make list row the link to details

sn00ze

New Member
Ok, this is driving me nuts and I'm sure someone here will just go "you forgot the semi colon" or something and I can sleep at night once more..

So, in an attempt to make the entire list row the link to the items details and not the magnifying glass button, I have been editing default_row.php
The issue is $this->_row->data->fabrik_view_url is not coming through to the browser... its hard to explain... I look at the source HTML and its there as expected ... but if I 'inspect element' in browser, the string is empty and of course the link doesnt work.

Here's the code. There's not much to it. you can see I've tried a few things with the var $click and urlencode. no joy :confused:

PHP:
<?php
/**
* Fabrik List Template: Admin Row
*
* @package    Joomla
* @subpackage  Fabrik
* @copyright  Copyright (C) 2005-2013 fabrikar.com - All rights reserved.
* @license    GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
 
// No direct access
defined('_JEXEC') or die('Restricted access');
//$click = $this->_row->data->slug;
//$click = $this->_row->data->fabrik_view_url;
 
$click = '/index.php?option=com_fabrik&amp;view=details&amp;formid=5&amp;rowid=' . urlencode($this->_row->data->slug);
?>
 
<tr style="cursor:pointer" id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>" onclick="document.location='<?php echo $click; ?>';" >
    <?php $i = 0;
        foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        if ($i == 0){
 
        ?>
        <?php } else {?>
        <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
            <?php echo @$this->_row->data->$heading;?>
        </td>
        <?php } $i++;}?>
</tr>

ps.
var_dump($click) gives

string(72) "/index.php?option=com_fabrik&amp;view=details&amp;formid=5&amp;rowid=132"

in view source which is whats expected... but when I inspect element I get string(0) ""
weird huh?!
 
I'm not quite sure what you're trying to do, or why your url isn't working.
Are you going to hide the looking glass icon with css? Do you intend the list to be editable?
Either way I don't think you'll need to alter any fabrik php code.

Why not just use the "Custom link" url in the "List view" settings for each element that gets shown in the list?
In that case your Custom link would be...
index.php?option=com_fabrik&view=details&formid=5&itemid=132

OR - If you intend for the form to be read-only (no editing or edit icon shown - and want only the details form) then just set the Access level for "Form (add)" and "Form (edit)" in every element to "Special" (or "Nobody" if you have that user group setup) - and so long as the "Show in list" and "Link to details" options of the List view settings in each element are set to Yes, the Details form for that row will be shown when any item in the row is clicked. (No need to enter any Custom links in that case)
 
thanks Bauer,
It turns out Ajax was stepping in somewhere and stripping my php added url. The temp solution was to disable Ajax for the list (Edit List -> details -> Navigation -> Ajaxify)

I don't know how or where ajax was causing the problem, it would be good to keep ajax on ??

For future searchers, this code is working (when Ajax is OFF!)
It replaces the magnifying glass view button with a click anywhere in the row as the link to view the record. Example here

You should make a custom list template see here: http://fabrikar.com/forums/index.php?wiki/creating-a-custom-list-template/
Then select your new template in (Edit List -> details -> Layout -> Front-end Template)

edit your new template's default_row.php to be below:

PHP:
<?php
/**
* Fabrik List Template: Admin Row
*
* @package    Joomla
* @subpackage  Fabrik
* @copyright  Copyright (C) 2005-2013 fabrikar.com - All rights reserved.
* @license    GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
 
// No direct access
defined('_JEXEC') or die('Restricted access');
?>
 
<tr style="cursor:pointer" id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>" onclick="document.location='<?php echo $this->_row->data->fabrik_view_url; ?>';">
    <?php $i = 0;
        foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
            if ($i != 0){
            ?>
                <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
                    <?php echo @$this->_row->data->$heading;?>
                </td>
        <?php }
        $i++;
        }?>
</tr>
 
I really like the idea of this however is there are another way of achieving the above without actually creating a custom template?
 
I learned a lot in the 3 1/2 years since this thread was created.:p
You could do the same thing with 2 lines of javascript/jquery.

This would be the code if using the default Fabrik bootstrap list template - assuming the list ID is 23 and the group ID is 26...
JavaScript:
jQuery("td.fabrik_list_23_group_26").on("click",  function(){
    jQuery(this).closest("tr").find("td.fabrik_actions div.btn-group a.fabrik_view")[0].click();
});
And maybe a little css for styling?...
CSS:
td.fabrik_list_23_group_26:hover {
    cursor:pointer;
}

td.fabrik_list_23_group_26 {
    color:blue;
}

/* hide details button altogether? */
td.fabrik_actions div.btn-group a.fabrik_view {
    display:none;
}

/* or  hide action buttons entirely? */
th.fabrik_actions,
td.fabrik_actions  {
    display:none;
}
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top