Dear all
First I want to say to the creators of connectivity v6 that - as I have been playing around with the demos - I came to appreciate that this is a great product! Fun to work with and interesting...It definitely fired up quite a few neurons in my brain!
Now my questions. I have two columns containing a UNIX timestamp. In the front end I want to display them as a date in the format say Y-m-d.
I managed to do this for each field in two ways.
The first: I created a function of type php on similar lines as in https://www.chronoengine.com/forums/posts/t102515/how-to-sum-two-or-more-collums-in-table-format.html
The second: I created an HTML view in which I used the same php code as the one I had in the php function to convert the UNIX datestamp into a date Y-m-d
However, to create 2 functions (or 2 HTML views) one for each field seems too much. Is there a way to define a php function that takes parameters? Can I pass the fields as a parameter to the php function? So then I would define it only once and use it multiple times on several columns.
I hope my explanations are clear🙂
Thank you
Kind regards
Amelia
First I want to say to the creators of connectivity v6 that - as I have been playing around with the demos - I came to appreciate that this is a great product! Fun to work with and interesting...It definitely fired up quite a few neurons in my brain!
Now my questions. I have two columns containing a UNIX timestamp. In the front end I want to display them as a date in the format say Y-m-d.
I managed to do this for each field in two ways.
The first: I created a function of type php on similar lines as in https://www.chronoengine.com/forums/posts/t102515/how-to-sum-two-or-more-collums-in-table-format.html
The second: I created an HTML view in which I used the same php code as the one I had in the php function to convert the UNIX datestamp into a date Y-m-d
However, to create 2 functions (or 2 HTML views) one for each field seems too much. Is there a way to define a php function that takes parameters? Can I pass the fields as a parameter to the php function? So then I would define it only once and use it multiple times on several columns.
I hope my explanations are clear🙂
Thank you
Kind regards
Amelia
Hi Amelia,
I'm glad you like the product!🙂
Unfortunately the feature you need does not exist yet, but its really important, so starting from the next update you will be able to pass variables to the functions and views when you call them, example:
Then in the PHP function you can use:
If you think the syntax should be improved or other features added then please do not hesitate to let me know.
Best regards,
Max
I'm glad you like the product!🙂
Unfortunately the feature you need does not exist yet, but its really important, so starting from the next update you will be able to pass variables to the functions and views when you call them, example:
{fn:php_function_name$myvar1=myvalue1&myvar2=myvalue2}
Then in the PHP function you can use:
$this->get("myvar1");
If you think the syntax should be improved or other features added then please do not hesitate to let me know.
Best regards,
Max
Hi Max,
I don't know if the actual version of CCv6 is ready for this, but if it is how can i pass variable on a colum view of a table?
I have many columns in my externalDB with date formatted unlike I need. So by now I create a PHP function for every field...
Now It'll be great to use a uniqe fn with variable like this: (fn:php1)
echo date("d/m/Y", strtotime($this->get("mydate")));
But in the view what can I write??
ddt.data:{fn:php1&mydate=?the date of this row and this column?}
Thanks a lot.
Marco
I don't know if the actual version of CCv6 is ready for this, but if it is how can i pass variable on a colum view of a table?
I have many columns in my externalDB with date formatted unlike I need. So by now I create a PHP function for every field...
Now It'll be great to use a uniqe fn with variable like this: (fn:php1)
echo date("d/m/Y", strtotime($this->get("mydate")));
But in the view what can I write??
ddt.data:{fn:php1&mydate=?the date of this row and this column?}
Thanks a lot.
Marco
Hi Marco,
If you have the new update released about 10 hours ago, then you can create a php function, lets say "php1", then call it from the table columns like this:
Now in the PHP function, you can use this code:
So its only 1 function now to do the processing, but the parameter value you pass changes.
Best regards,
Max
If you have the new update released about 10 hours ago, then you can create a php function, lets say "php1", then call it from the table columns like this:
{fn:php1$mydate=(view:table_view_name.row.Model.field_name)}
Now in the PHP function, you can use this code:
echo date("d/m/Y", strtotime($this->get("mydate")));
So its only 1 function now to do the processing, but the parameter value you pass changes.
Best regards,
Max
Ciao Max,
it seems that the variable $mydate=(view.etc...) isn't passed to the function...
The result on my table is 01/01/1970 for all the rows.
I have also try with
with {debug:} I can't find anything useful to understand.
thanks
Marco
it seems that the variable $mydate=(view.etc...) isn't passed to the function...
The result on my table is 01/01/1970 for all the rows.
I have also try with
$mydate=(var:read_fn_name.row.Model.field_name)
but nothing change.
with {debug:} I can't find anything useful to understand.
thanks
Marco
Hey,hey..forgive me.
I found the syntax error..
The variable needs "var" not "view".. and then the table_view_name
It's all ok, and It's a very great upgrade.
goodnight
Marco
I found the syntax error..
{fn:php1$mydate=(var:table_view_name.row.Model.field_name)}
The variable needs "var" not "view".. and then the table_view_name
It's all ok, and It's a very great upgrade.
goodnight
Marco
Hi Marco,
Good catch, it was a mistake in my code!🙂
Best regards,
Max
Good catch, it was a mistake in my code!🙂
Best regards,
Max
This topic is locked and no more replies can be posted.