Template for list - 2 fields in 1 column.

I have a problem with lists that have many number of colums.

Now i try to make lists that have width = 1280px (not more)

So, my problem is how to code:
Column 5
--------------
fields 5
fields 6


Column 6
-----------------
field 7
field 8



All other colums should be: 1 column --> 1 field

Can i get tip how to modify "default" Fabrik list to include change: "Column 5" --> 2 fields and "Column 6" --> 2 fields ?
 
"quick &dirty" (I didn't test):
create a custom template (copy default)
edit default_row.php
PHP:
...
<tr id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">

    <?php 
    $i=1;
    foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <?php  /*if field 6 or 8 don't display <td> but linebreak*/
        if ($i!=6 and $i!=8) {?>
            <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
        <?php}?>
            <?php echo @$this->_row->data->$heading;?>
        <?php 
        if ($i!=6 and $i!=8) echo '</td>';
        else echo '<br/>';
        i=$i+1;
    }?>
</tr>
Do the same in default_headings.php
 
The alternative would be to use placeholders in a calc element to build the combined columns, like ...

return "{tablename___element_5} {tablename___element_6}";

Hide that in form view, show it in list view, and don't show the original columns in list view.

-- hugh
 
"quick &dirty" (I didn't test):
create a custom template (copy default)
edit default_row.php, Do the same in default_headings.php

I have a problem to code this right:
default_headings.php
Code:
<?php
/**
 * Fabrik List Template: Default Headings
 *
 * @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;
?>

<tr class="fabrik___heading">
<?php
    $i=1;
 foreach ($this->headings as $key => $heading) {
        $style = empty($this->headingClass[$key]['style']) ? '' : 'style="'.$this->headingClass[$key]['style'].'"';?>
        <?php  /*if field 6 or 8 don't display <td> but linebreak*/
        if ($i!=6 and $i!=8) {?>

        <th class="<?php echo $this->headingClass[$key]['class']?>" <?php echo $style?>>
<?php
}
?>
                <span class="heading"><?php echo  $heading; ?></span>

                <?php if (array_key_exists($key, $this->filters) && ($this->filterMode === 3 || $this->filterMode === 4)) {
                        $filter = $this->filters[$key];
                        $required = $filter->required == 1 ? ' notempty' : '';
                        echo '<div class="listfilter' . $required . '">
                        <span>' . $filter->element . '</span></div>';
                }?>
        <?php 
        if ($i!=6 and $i!=8) echo '</th>';
        else echo '<br/>';
        $i=$i+1;

    }?>

</tr>

default_row.php
Code:
?php
/**
 * Fabrik List Template: Default Row
 *
 * @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;
?>


<tr id="<?php echo $this->_row->id;?>" class="<?php echo $this->_row->class;?>">

    <?php 
    $i=1;
    foreach ($this->headings as $heading => $label) {
        $style = empty($this->cellClass[$heading]['style']) ? '' : 'style="'.$this->cellClass[$heading]['style'].'"';
        ?>
        <?php  
//if field 6 or 8 don't display <td> but linebreak
        if ($i!=6 and $i!=8) {?>
            <td class="<?php echo $this->cellClass[$heading]['class']?>" <?php echo $style?>>
        <?php
}
?>
            <?php echo @$this->_row->data->$heading;?>
        <?php 
        if ($i!=6 and $i!=8) echo '</td>';
        else echo '<br/>';
        $i=$i+1;
    }?>
</tr>

It doesn't work properly.
Fields6 and field8 disappear from the list.
 

Attachments

  • list___1column_with_2fields--a.png
    list___1column_with_2fields--a.png
    88.7 KB · Views: 362
The alternative would be to use placeholders in a calc element to build the combined columns, like ...

return "{tablename___element_5}
{tablename___element_6}";

Hide that in form view, show it in list view, and don't show the original columns in list view.

-- hugh
I would rather to use the way shown by troester - so i can use it for more than 1 list. So, it doesn't work for me yet in this moment.

But i try your way with calc element - i can confirm it works.
Howewer i have some smaller problems with calc element.
I use:
Code:
return "{ccjom_cc_klienci_zgl_naprawy___wprowadzajacy_auto}<br/>
{ccjom_cc_klienci_zgl_naprawy___date_time}";

In my calc element i use fields: user-field+date-field.
I need:
1. sort by field that is calc-element..
Now, I use: "Allow ordering" option for calc element but this doesn't sort properly - see screenshots. Is possible to sort by both 2 fields that are included in calc?.

2. I have in calc element - field-date_time - i don't need time selector in it - but it show time
even though in source "date-time"-element i have - not show time selector.

3. can i get "empty" field data_time in calc when source field "data_time" is empty - not 0000-00-00?

On screenshot i have calc-element=Wprowadz.+Data zg?osz combined with field-date-time=Data zg?oszenia and field-user=Wprowadzaj?cy.

-----------------------
I have also problem how to set up for an element/field:
1. Show on list + Hide on record view ?
I try : Edit:elements --- Show in list - V (Yes), Publish - - (No, unpublish) - but then it doesn't show both in list and in record view (or record edit)
 

Attachments

  • element_calc___not_sorting_corectly.png
    element_calc___not_sorting_corectly.png
    37.7 KB · Views: 299
I think the calc would be the best way, its would be fairly complex php coding to set up something generic enough to handle merging specific columns on any list.

. Is possible to sort by both 2 fields that are included in calc?.
You would have to have the calc set to 'Only Calc on Save' : 'yes' so that it actually stores the calculations in the database. Otherwise ordering will not be possible.

2. I have in calc element - field-date_time - i don't need time selector in it - but it show time
even though in source "date-time"-element i have - not show time selector.

3. can i get "empty" field data_time in calc when source field "data_time" is empty - not 0000-00-00?

Code:
$date = '{ccjom_cc_klienci_zgl_naprawy___wprowadzajacy_auto}';
if ($date == '0000-00-00 00:00:00') {
  $date = '';
} else {
  $date = JFactory::getDate($date);
  $date = $date->toFormat('%Y-%m-%d');
  $date .= '<br/>';
}
return "$date{ccjom_cc_klienci_zgl_naprawy___date_time}";

I have also problem how to set up for an element/field:
1. Show on list + Hide on record view ?
I try : Edit:elements --- Show in list - V (Yes), Publish - - (No, unpublish) - but then it doesn't show both in list and in record view (or record edit)
Publish no will unpublish the element from all view.
I see what you mean with the access levels, the details one alters both the details view and the list view.
In github I've just added a separate list access level control for the element, which should mean that under the element's access tab you can select:

Form view: special
Details view: special
List view: public

(the element still needs to be published and set to show in the list)
 
Just to clear up some lingering confusion with the "Only Calc on Save" option. The calc element ALWAYS saves it's value when saving the form, regardless of this setting. The difference is, if "Only Calc on Save" is set to "Yes", the value will NOT be re-calculated when rendering in things like lists and details view. If set to "No", we re-calculate the element's value every time we display it.

Note that for things like ordering, the saved value will be used, even if "Only Calc on Save" is set to No. This is because ordering is done in the MySQL query, which obviously happens before we have the data for the row, so it's a chicken and egg. We can't order the query on a re-calculated value, only on the last saved value.

-- hugh
 
I use option: "Only Calc on Save"=No, so i use it on my list3 that is only registry - list-view+record-view - i don't input records on this list (and i don't edit records on list3)
I have earlier list1 for the same database table where records are added - and where i don't use calc.

So, is not possible to sort by column that is calc on my list3?

My all tasks in fabrik have some standard:
i use 3 or 4 lists for 1 database table - that is 1 task/item, i have:
list1 - "add records" - only new records are added - and only some fields are fulfilled.
list2 - "edit records" - i can only modify records = i can fulfil for first time fields that were not used on list1
list3 - "list-view"+"record-view" - i only view records - not use "add", not use "edit"
 
rob:
the result of code:
Code:
$date = '{ccjom_cc_klienci_zgl_naprawy___date_time}';
if ($date == '0000-00-00 00:00:00') {
  $date = '';
} else {
  $date = JFactory::getDate($date);
  $date = $date->toFormat('%y-%m-%d');
  $date .= '<br/>';
}


return "$date{ccjom_cc_klienci_zgl_naprawy___date_time}
<br/>{ccjom_cc_klienci_zgl_naprawy___wprowadzajacy_auto}";

is not without hour and not empty when date_time is empty.
Now is without "year".
 

Attachments

  • 4.png
    4.png
    36.4 KB · Views: 301
Code:
$date = '{ccjom_cc_klienci_zgl_naprawy___date_time}';
if ($date == '0000-00-00 00:00:00') {
 $date = '';
 } else {
 $date = JFactory::getDate($date);
 $date = $date->toFormat('%Y-%m-%d');
 $date .= '<br/>';
 }
 return "$date {ccjom_cc_klienci_zgl_naprawy___wprowadzajacy_auto}";
perhaps?
 
rob: The code doesn't work OK - i get only "user" in calc column.
-------------------------------------------------------------------------------------------

But my main problem is to sort by calc column.
I need option: "Only Calc on Save"=No

I use option: "Only Calc on Save"=No, so i use it on my list3 that is only registry - list-view+record-view - i don't input records on this list (and i don't edit records on list3)
I have earlier list1 for the same database table where records are added - and where i don't use calc.

So, is not possible to sort by column that is calc on my list3?
---------------------------------------------------------------------------------------------

My all tasks in fabrik have some standard:
i use 3 or 4 lists for 1 database table - that is 1 task/item, i have:
list1 - "add records" - only new records are added - and only some fields are fulfilled.
list2 - "edit records" - i can only modify records = i can fulfil for first time fields that were not used on list1
list3 - "list-view"+"record-view" - i only view records - not use "add", not use "edit"
 

Attachments

  • 6.png
    6.png
    25.8 KB · Views: 271
But my main problem is to sort by calc column.
I need option: "Only Calc on Save"=No

I use option: "Only Calc on Save"=No, so i use it on my list3 that is only registry - list-view+record-view - i don't input records on this list (and i don't edit records on list3)
I have earlier list1 for the same database table where records are added - and where i don't use calc.

So, is not possible to sort by column that is calc on my list3?
No its not, this is the order that fabrik does things in:

1) Build the query including the ordering
2) Format the element data based on element settings

So if your list is never saving records we can't store the results in the database and thus can't order by the results, which are generated in step 2.

the only solution I can think of is to write a cron script which does the same thing as your calculation element - but that's getting into complex(ish) PHP.
 
I'm somewhat confused.

You have a version of the list in which you add records, and a version where you edit records. But you say:

I have earlier list1 for the same database table where records are added - and where i don't use calc.

Surely the answer is to simply use the calc on the copies of the list where you add and edit rows? As far as I can tell, your calc is derived using only element data from the same row. And from your description, that data is input and edited only through Fabrik. So you don't need to re-calc every time you render, so "Only Calc On Save" can be Yes, as long as it gets run when you add or edit the rows.

If you need to fill the data for existing rows, i.e. data for rows already in the table which existed before you added the calc, you should be able to do it with a one-off query in phpMyAdmin. Something like ...

UPDATE yourtable SET yourcalc = CONCAT(DATE_FORMAT('%Y-%m-%d', date_time), ' ', wprowadzajacy_auto)

... or whatever CONCAT you need to generate the data in the format you need. Which you can work on by just running it as a SELECT while you test the CONCAT() ...

SELECT CONCAT(..whatever...) AS foo FROM yourtable

... until it gives you the expect format.

Once the calc element has been pre-set like this one time, as long as you run the calc itself on the add/edit versions of the list, to format the data when new rows are added or rows are edited, you'll be good to go.

You could even change the element type in your "no adding or editing" copy of the list to be just a field, which would reduce complexity.

-- hugh
 
I try now to use calc element with option "Only calc on Save"=Yes
It works - ... but sorting is only for "first-field1" in "calc-field"= field1 + field2

It would be an advantage for me, if this was possible:

1. sort calc column when calc=field1 + field2 + field3 not by first field1 but by field2 or field3

2. the nice would be add second small "icon=sort2" to choose sort with "icon=sort1" by field1 or sort with "icon=sort2" by field2

Is this possible?

My calc element has calculation:
Code:
return "{ccjom_cc_klienci_sugestie___address}<br/>
{ccjom_cc_klienci_sugestie___email}";
and calc element is:
{ccjom_cc_klienci_sugestie___adres_i_email}
 

Attachments

  • 171a.png
    171a.png
    61.6 KB · Views: 286
Hmmmm. Short answer, I don't really see any way of sorting the way you want, without having separate columns for those fields.

Is part of the issue you are trying to work round to do with the width of the list, so it fits on a "normal" sized browser window?

If so, we might be able to work round it with some custom template code to hide/show certain columns.

-- hugh
 
I have this problem for tables with long width - we assume that basic monitor for our joomla + fabrik is 1280 px witdh (screen 17 or 19 inch with 1280px width) .

If possible to make in custom template hide/show column it could be one of solution in that matter...
 
troester:
It works for me.
It is fine. But is possible to set "starting" parameter for choosen columns to "hide" in checboxes (when open or reopen page with list)?
 
You should just be able to leave out the checked='checked' when building the checkboxes in your template.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top