Hi I have this php code working on CCv5 but I am trying to translate it to ccv6 in where conditions in a read field function
<?phpthis simple code works on ccv6
if(!empty($_POST['filtername1']) && !empty($_POST['filtertext1'])){
$filter1 =$_POST['filtername1'];
$text1=$_POST['filtertext1'];
if(!empty($_POST['filtername2']) && !empty($_POST['filtertext2'])){
$filter2 =$_POST['filtername2'];
$text2=$_POST['filtertext2'];
return array(":{$filter1} LIKE" => "%{$text1}%" , ":{$filter2} LIKE" => "%{$text2}%" );
}else{
return array(":{$filter1} LIKE"=>"%{$text1}%");
}?>
<?phpand also works to assign a variable to field value
return [["venta.num","1997"]];
?>
<?phpbut I couldn't make variable the field to search that comes from a dropdown, is it possible in ccv6?, for example this simple test
return [["venta.num","{data:valor1}"]];
?>
<?phpgives me this error 1054Unknown column 'venta.:{data:filtro1_sel}' in 'where clause'
$this->data['filtro1_sel']="num";
$this->data['valorl']="1997";
return [[":{data:filtro1_sel}","{data:valor1}"]];
?>
Hi Teldrive,
Did you try the new v7 ? the "Search listing" behavior in the Text fields can be added to multiple fields and it would apply the where conditions to the list automatically!
Did you try the new v7 ? the "Search listing" behavior in the Text fields can be added to multiple fields and it would apply the where conditions to the list automatically!
Hi Max
I see only version 6 in chronoengine web , anyway is there any possibility to assign variable to field condition? I have a lot of work done in v6
I see only version 6 in chronoengine web , anyway is there any possibility to assign variable to field condition? I have a lot of work done in v6
Hi Teldrive,
The beta version of CFv7 is available from the Blog menu above.
Bob
The beta version of CFv7 is available from the Blog menu above.
Bob
hi bob I will try, but for a production solution is very risky go ahead with beta. I understand there is not work around for this topic in ccv6
thanks anyway
thanks anyway
In your conditions, just put in all the fields and choose "skip" or "ignore" if it's null.
Or if you absolutely must have a dropdown, then you'll just have to build the query yourself.
Or if you absolutely must have a dropdown, then you'll just have to build the query yourself.
Hi healyhatman, thanks by the clue, sometimes I forget the ccv6 flexibility, but some i need some adittional help
$this->data['filtro1_sel']="num";this works fine, but when try with the variable field "$db->quote($filter1)", fails
$this->data['valor1']="1997";
//---------------------------starts query
$db = JFactory::getDbo();
// Create a new query object.
$query1 = $db->getQuery(true);
$query1->select($db->quoteName(array('id','ano','bruto','neto','iva','irpf','fechaini','tipoventa')));
$query1->from($db->quoteName('#__cf_venta'));
$filter1=$this->data['filtro1_sel'];
$text1=$this->data['valor1'];
//$query1->where($db->quote($filter1)." LIKE ".$db->quote($text1));
$query1->where($db->quoteName('num')." LIKE ".$db->quote($text1));
$query1->order($db->quoteName('fechaini').'DESC');
$db->setQuery($query1);
return $db->loadAssocList();
$query1->where($db->quote($filter1)." LIKE ".$db->quote($text1));is something missing?, by the way how can I request model "venta" into to query1 I tried with
$query1->from($db->quoteName('#__cf_venta','venta'));but it doesn't work
I think the code at the first post will be something like this:
$where = [];
if(1){$where = ["field1", "value1", "="];}// you may replace "=" by LIKE
return $where;
Hi Max, thanks by this other method, I tried and works but it necessary the double bracket not sure why
<?phpI was wrong before because is not possible to pass variable to field or value , I am not sure if I am missing something
$this->data['filtro1_sel']="num";
$this->data['valor1']="1997";
if(1){$where = ["num", "1997", "="];}
return [$where];
?>
if(1){$where = ["num", "{data:valor1}", "="];}by the way let me ask if you can help how to get a "model" based array using query when I return "$db->loadAssocList()" I think this could be a workarund;
if(1){$where = ["{data:filtro1_sel}", "{data:valor1}", "="];}
yes, it's necessary to use double brackets, because this is a group of where settings!
you do not have to use if(1), that was just an example!
The loadAssocList is a Joomla function, the model array is a gcore feature, you need to use the GCore code for that!
and I do not think it's a good idea to get the field name by the {data:} call like you do now {data:filtro1_sel}
you do not have to use if(1), that was just an example!
The loadAssocList is a Joomla function, the model array is a gcore feature, you need to use the GCore code for that!
and I do not think it's a good idea to get the field name by the {data:} call like you do now {data:filtro1_sel}
Hi Max, awaiting any clue about how can I generate a model array with Gcore ;-) or how can generate "where conditions" with variable field-value as in ccv5 (if possible) Anyway opening my mind and exploring all posibilities I decided to try CFv7
I see Cfv7 has very high potential if possible to merge cc and cf in one package, I miss some demos ,
trying to implement a basic ccv6 viewlist I am working on i think this integration can be with module "table list" , but how do I define source data for this table?
fighting until find a solution🧐
I see Cfv7 has very high potential if possible to merge cc and cf in one package, I miss some demos ,
trying to implement a basic ccv6 viewlist I am working on i think this integration can be with module "table list" , but how do I define source data for this table?
fighting until find a solution🧐
"where conditions" with variable field ? you mean like in your first post ? just use my code and instead of "if(1)" use your own condition!
There is a FAQ on how to work with GCore database models class, but you do not need that since you can just use the "Read Data"
You can find attached a basic articles listing in v7, I hope it helps!
There is a FAQ on how to work with GCore database models class, but you do not need that since you can just use the "Read Data"
You can find attached a basic articles listing in v7, I hope it helps!
Hi Max, we got it, this code works with one search filed where condition with parameters field and value😀
(i insert pictures because blog process brackets )

just a little adittional help , how can I combine two where conditions( if possible), I tried two options without sucess

(i insert pictures because blog process brackets )
just a little adittional help , how can I combine two where conditions( if possible), I tried two options without sucess
return [$where]." AND ".[$where];and
your syntax is wrong, it should be like this:
return [["field1", "value1", "="],"AND",["field2","value2","LIKE"]];And so on!
Thanks a lot Max, in special your week-end attention, let me share here the final code, for sure will help a lot of people, I had to use "Like" in both where conditions in order to they understand "%"
This topic is locked and no more replies can be posted.