• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[Solved]: List Div Custom Template & Ajax Navigation

sunnyjey

Active Member
I have created custom Div List template to output required field like:

My default_row.php :

Code:
// No direct access
defined('_JEXEC') or die('Restricted access');
$rowClass = isset($this->_row->rowClass) ? $this->_row->rowClass : '';

$myelement = $this->_row->data->mytable___myelement_name;

?>
    <div ="row-fluid">
             <?php echo $myelement;?>
</div>

When I select Ajaxify List : NO. It echoes correct Element_Name.

For eg:
RowID 1: Name1
RowID2: Name2
RowID3: Name3
.....

BUT, When I activate Ajaxify Navigation to YES, it echoes Element_Name of First Row in all Pages and rows.

For eg:
RowID 1: Name1
RowID2: Name1
RowID3: Name1
.....

I have gone through multiple threads in forum for last 3 hours but didn't find the solution.

NB: Latest J! and Latest F! (updated 2 days ago). The default DIV template works well on Ajax Navigation.
 
Last edited:
For the ajax update you must keep the structure with HTML ids and classes.

So default.php has a <div ... id="list_3_com_fabrik_3_row_77.... (created by bootstrapGrid)

Usually default_row.php includes a loop on your elements especially including the id element.
 
I'm sorry, but I cannot figure out as it is beyond my comprehension.

What changes are required in default.php and default_row.php of DIV template.

Can you please give me example .
 
You say "the default div works well", so use this as example and change as less as possible to meet your needs.
Did you modify default.php?
Is your id element published?
 
You say "the default div works well", so use this as example and change as less as possible to meet your needs.
Yes, DIV works flawlessly. Even the custom non-ajax LIST template works. I have to add additional static text prefix to the Element, for e.g This item name is <?php echo $myelement;?> So it is not possible, unless I do some changes in default_row.php

Did you modify default.php?

No. Do I need to modify it ?

Is your id element published?
Yes. I have checked with different list and different J! template (Protostar), but same error.
 
Thanks to the @startpoint . The following template is nicely working with on-fly Ajax Navigation of the List. Ref Thread: http://fabrikar.com/forums/index.php?threads/custom-templates.50465/#post-263764

PHP:
<?php
// No direct access
defined('_JEXEC') or die('Restricted access');

$rowClass = isset($this->_row->rowClass) ? $this->_row->rowClass : '';
$user = JFactory::getUser()->groups;
$userKeys = array_keys($user);
// the first element of your array is:
$userGroup = $user[$userKeys[0]];

$list_data = array();
foreach ($this->headings as $heading => $label) :
    $elem_data = new stdClass;
    $h = $this->headingClass[$heading];
    $c = $this->cellClass[$heading];
    $hStyle = empty($h['style']) ? '' : 'style="' . $h['style'] . '"';
    $cStyle = empty($c['style']) ? '' : 'style="'. $c['style'].'"';
    $lbl = $label;
    $lbl_class = $h['class'];
    $el_class = $c['class'];
    $el_data = @$this->_row->data->$heading;
    if($heading !== 'fabrik_select' && $heading !== 'fabrik_actions'){
        $el_name = explode ("___", $heading)[1];
        $elem_data->el_name = $el_name;
        $elem_data->el_lbl = $lbl;
        $elem_data->lbl_class = $el_class;
        $elem_data->el_class = $el_class;
        $elem_data->el_data = $el_data;  
        $list_data[$el_name] = $elem_data;
    }
       
    if($heading == 'fabrik_actions'){
        $actions_class = $el_class;
        $actions = $el_data;
        $elem_data->actions_class = $actions_class;
        $elem_data->actions = $actions;
        $list_data[$heading] = $elem_data;      
    }
    if($heading == 'fabrik_select'){
        $select_class = $el_class;
        $select = $el_data;
        $elem_data->select_class = $select_class;
        $elem_data->select = $select;
        $list_data[$heading] = $elem_data;
    }
  
    $d = @$this->_row->data->$heading;
    if (isset($this->showEmpty) && $this->showEmpty === false && trim(strip_tags($d)) == '') :
        continue;
    endif;
endforeach;
//echo '<pre>list_data' . var_export($list_data, true) . '</pre>';
?>
<div class="<?php echo $rowClass; ?>">
    <div class="row-fluid fabrikDivElement">      
        <div class="movie-container">
            <div class="<?php echo $list_data['element_name1']->el_class ?>">
                <?php echo $list_data['element_name1']->el_data ?>
            </div>
            <div class="<?php echo $list_data['element_name2']->el_class ?>">
                <?php echo $list_data['element_name2']->el_data;?>
            </div>
        </div>
        <?php if($userGroup == 6 || $userGroup == 8) : ?>
        <!--
            usergroup 6 -> Custom admin
            usergroup 6 -> Super User
        -->
            <div class="<?php echo $list_data['fabrik_actions']->actions_class ?>">
                <?php echo $list_data['fabrik_actions']->actions ?>
            </div>
            <div class="<?php echo $list_data['fabrik_select']->select_class ?>">
                <?php echo $list_data['fabrik_select']->select ?>
            </div>          
        <?php endif; ?>
    </div>
</div>

But, I am finding two difficulties
  1. Total number of Rows displayed in a Page works for just First page and for others it is random. I have set limit=5 in content plugin. So for first page it displays 5 rows, but when I navigate to 2nd or 3rd page, the limit do not work.
  2. I want to display total n number of Rows, hence I tried to filter the List to display only rows from Last month using date_time element.
Both $limit & $filter works for bootstrap non-ajax template, but when I use above template they don't. I don't know how to include Filter and Limit option in this DIV Ajax template. Any pointers please.
 
I can't replicate (with the standard div template).
content plugin with limit=5 is working fine during navigation
So as long as you didn't modify anything in default.php it should do.

Did you use the recent div template as starting point?
 
Yes. Indeed I had made changes in custom layout footer.php. I copied the original footer.php and limit is working fine during navigation.

Thank you very much for taking time to test this issue and helping me out.
 
I have a new problem. I have joined List to the Primary Ajax List. How do I echo the list data from joined list to this Ajaxified List ?
 
When I ECHO

Code:
echo '<pre>list_data' . var_export($list_data, true) . '</pre>';

I am getting following ouput.

Code:
list_dataarray (

// // ----EMPTY OUPUT---- FOR JOINED TABLE IN AJAXIFIED LIST !!!

  'database_id' =>
  stdClass::__set_state(array(
     'el_name' => 'database_id',
     'el_lbl' => 'Test',
     'lbl_class' => 'joined_table___database_element_id fabrik_element fabrik_list_X_group_185 repeat-merge',
     'el_class' => 'joined_table___database_element_id fabrik_element fabrik_list_X_group_185 repeat-merge',
     'el_data' => '
',
  )),

// NORMAL OUPUT FOR JOINED TABLE IN AJAXIFIED LIST

  'id' =>
  stdClass::__set_state(array(
     'el_name' => 'id',
     'el_lbl' => 'id',
     'lbl_class' => 'joined_table___id fabrik_element fabrik_list_X_group_185 repeat-merge',
     'el_class' => 'joined_table___id fabrik_element fabrik_list_X_group_185 repeat-merge',
     'el_data' => '549',
  )),
 
// NORMAL OUPUT FOR PRIMARY TABLE IN AJAXIFIED LIST
  'name' =>
  stdClass::__set_state(array(
     'el_name' => 'name',
     'el_lbl' => 'Name',
     'lbl_class' => 'primary_table___name fabrik_element fabrik_list_X_group_XY',
     'el_class' => 'primary_table___name fabrik_element fabrik_list_X_group_XY',
     'el_data' => 'John',
  )),

)

It looks, Fabrik is outputting correct data for non-array field, but for array-joined element (in my case database Element), it is not echoing anything !! Any help will be highly appreciated.
 
I have a new problem. I have joined List to the Primary Ajax List. How do I echo the list data from joined list to this Ajaxified List ?
Hello ,
Did you find a way to echo the list data from joined list to this Ajaxified List?
I need that please
thank you
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top