• 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.

Get filter data (cascadingdropdown) PHP

Hi,
I have Joomla 2.5.28 and fabrik 3.0.9

I try to capture cascading dropdown variable from filter and use them in a calculation element.
I don't know what syntax to use to capture a data that is cascadingdropdown. (I could try it also for data field if this would be simpler)
I found on forum thread:
http://fabrikar.com/forums/index.php?threads/get-filter-data-dates-php.22273/
where is something - code for filter data - and i try use it to my example.

It is new function for me and i have no idea how to modify this code,
I try this:


PHP:
echo "----- Test 1 --- Sum  pakietow AA:   <br/>";
$db =& JFactory::getDBO();
$table =& JModel::getInstance( 'Table', 'FabrikModel' );
$table->setId(331); //replace 1 with your table id
$filters = $table->getRequestData();
$keys = JArrayHelper::getValue( $filters, 'key', array() );
$vals = JArrayHelper::getValue( $filters, 'value', array() );

//echo "<pre>";print_r($keys);echo '</pre>';
        for ($i = 0; $i < count($filters); $i++) {
            if (JArrayHelper::getValue( $keys, $i, '') === '`ccjom_cc_kk_karta_rejestr`.`zamow_symbol`') {
                $var_keg = $vals[$i];
$order1 = $var_keg[0];
            }   
        }

echo " Nr zam ---- $order1";


$query = "SELECT  `is_pak_xxxx` FROM  `ccjom_cc_kk_karta_rejestr` WHERE  (`rodzaj_karty_np_wzorzec`='2' AND `zamow_symbol`=".$order1.")  ORDER BY `id`";
$db->setQuery($query);
$result = $db->loadResult();

$resaa = mysql_query($query);
$rrraa=array();
$n=0;
while($row = mysql_fetch_array($resaa))
   {
       $rrraa[$n]=  $row['is_pak_xxxx'];
$n++;
               }
$newrrraa = array_count_values($rrraa);
                                foreach ($newrrraa as $key => $value) {
$query = "SELECT  `is_pak_wejsc_analog_aa` FROM  `ccjom_cc_kk_is_aa` WHERE `id`=$key ";
$db->setQuery($query);
$result1 = $db->loadResult();
echo "$result1 ------ <strong>$value</strong> <br />"; }
echo "<br/>";

I get an error:
Fatal error: Call to a member function setId() on a non-object in /var/www/cc.joomla/components/com_fabrik/views/list/tmpl/default-2015-09-11-table-kp5/default.php on line 160


can i get any tip how to code my variable for field: '`ccjom_cc_kk_karta_rejestr`.`zamow_symbol`' that is cascading dropdown or any simpler code for field : '`ccjom_cc_kk_karta_rejestr`.`testfied1`' that can be type "field". ?
 
The mentioned thread is about Fabrik2...

In an element's default you can get a filter value via

FabrikHelperElement::filterValue(81); //with 81 = filter's element id, zamow_symbol's id in your case I assume
 
This 1 nice line really works !!! Thanks :)

My code is:
PHP:
$db =& JFactory::getDBO();
$order1 =FabrikHelperElement::filterValue(11152); //with 81
if ($order1==0){
$zam1 = 'Razem wszystkie zam?wienia';
}
else {
$query = "SELECT  `ip2_zamowienie_symbol1` FROM  `ccjom_cc_kk_ip2_zamowienie`  WHERE  `id`= ".$order1."  ";
$db->setQuery($query);
$result = $db->loadResult();
$zam1 = $result;
}


echo " -- Zam?wienie nr: $zam1 -- <br/><br/>";

echo "----- Test 1 -----  Sum  pakietow AA:   <br/>";


if ($order1==0){
$query = "SELECT  `is_pak_xxxx` FROM  `ccjom_cc_kk_karta_rejestr` WHERE  `rodzaj_karty_np_wzorzec`= '2'  ORDER BY `id`";
}
else {
$query = "SELECT  `is_pak_xxxx` FROM  `ccjom_cc_kk_karta_rejestr` WHERE  `zamow_symbol`=".$order1."  ORDER BY `id`";
}

$db->setQuery($query);
$result = $db->loadResult();

$resaa = mysql_query($query);
$rrraa=array();
$n=0;
while($row = mysql_fetch_array($resaa))
   {
       $rrraa[$n]=  $row['is_pak_xxxx'];
$n++;
               }
$newrrraa = array_count_values($rrraa);
                                foreach ($newrrraa as $key => $value) {
$query = "SELECT  `is_pak_wejsc_analog_aa` FROM  `ccjom_cc_kk_is_aa` WHERE `id`=$key ";
$db->setQuery($query);
$result1 = $db->loadResult();
echo "$result1 ------ <strong>$value</strong> <br />"; }
echo "<br/>";


Hovewer i get small error. When in Joomla configurations is set : error reporting = maximum

i get result:
Notice: Undefined offset: 0 in /var/www/cc.joomla/components/com_fabrik/helpers/element.php on line 91 -- Zam?wienie nr: Razem wszystkie zam?wienia --

----- Test 1 ----- Sum pakietow AA:
2 x (In/2In) + 2 x 3Un ------ 30
3 x (In/50In) +Io ------ 26

--------------
Case: $zam1 = 'Razem wszystkie zam?wienia';
is for all "orderings no" in my table1 when i don't use filter in "search/filter subtable"
 
Last edited:
I don't know from your code what line 91 is.
Generally you should google for PHP notices - there will be lots of advice out there on what they mean. Quicker than waiting for a reply from us :)
 
Hmmmm,
I am not advanced in fabrik code and line 91 is in fabrik file:
/var/www/cc.joomla/components/com_fabrik/helpers/element.php

line 91 ---- $value = $filters['value'][$index];
sample of this code with line 91:
PHP:
public static function filterValue($elementId)
    {
        $app = JFactory::getApplication();
        $pluginManager = FabrikWorker::getPluginManager();
        $model = $pluginManager->getElementPlugin($elementId);
        $listModel = $model->getListModel();
        $listid = $listModel->getId();
        $key = 'com_fabrik.list' . $listid . '_com_fabrik_' . $listid . '.filter';
        $filters = JArrayHelper::fromObject($app->getUserState($key));
        $elementIds = (array) JArrayHelper::getValue($filters, 'elementid', array());
        $index = array_search($elementId, $elementIds);
        $value = $filters['value'][$index];

        return $value;
    }

Error is displayed for case:
$db =& JFactory::getDBO();
$order1 =FabrikHelperElement::filterValue(11152); //with 81
if ($order1==0){
$zam1 = 'Razem wszystkie zam?wienia';
}

when case is "else":
else {
$query = "SELECT `ip2_zamowienie_symbol1` FROM `ccjom_cc_kk_ip2_zamowienie` WHERE `id`= ".$order1." ";
$db->setQuery($query);
$result = $db->loadResult();
$zam1 = $result;
}

this error is not displayed.

Using "google" - i read that problem is in my code with line:
$order1 =FabrikHelperElement::filterValue(11152); //with 81

when in Search/Filter-Table element (11152) is not set (= this field is empty)
this line cause this error.

But i don't know how to fix this probably bug?


May be is possible to modify my code:
$db =& JFactory::getDBO();
$order1 =FabrikHelperElement::filterValue(11152); //with 81
if ($order1==0){
$zam1 = 'Razem wszystkie zam?wienia';
}


to something like:
$db =& JFactory::getDBO();
if (FabrikHelperElement::filterValue(11152) is not set)
{$order1 == 0;}
else
{$order1 =FabrikHelperElement::filterValue(11152); //with 81}

if ($order1==0){
$zam1 = 'Razem wszystkie zam?wienia';
}
......

Can I get any more advanced tip?
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top