Buy Now
Sign in

How to select data reader from switch

pdforest , March 05 2020, 21:10
P
pdforest 20
March 05 2020, 21:10 #391518
Hi, I need some help switching a data reader using the user code {session: user.id}
I have 2 data readers {fn:read_datos} and {fn:read_datos_todos}
The switch {fn:switch_read} uses {session:user.id} as data provider, the return the result as var is checked and has the following actions:
/^36[0-6]$/:read_datos_todos{fn:read_datos_todos}
/^36[7-9]$/:read_datos{fn:read_datos}
/^37[0-9]$/:read_datos{fn:read_datos}
The problem is in the view {view:datos_list_table} using the data provider {var:switch_read}
Debug:
[switch_read] => Array
(
[finished] => 1
[var] => read_datos
)
The name of the data reader is returned but the view cannot use it.
Thanks in advance!
SWITCH
switch1.png
VIEW
view1.png
G
gix.vax 119
March 05 2020, 21:52 #391519
hi
is there a reason you put the name of read_action after ":" ??
/^36[0-6]$/:read_datos_todos{fn:read_datos_todos}
try
/^36[0-6]$/:{fn:read_datos_todos}
/^36[7-9]$/:{fn:read_datos}
/^37[0-9]$/:{fn:read_datos}
P
pdforest 20
March 05 2020, 22:11 #391521
Hi, I put it there in order to be used by the view as the data provider.
If I put {fn:read_datos} in the view it works ok but i need the data provider to be changed matching the user code in the regex.
P
pdforest 20
March 10 2020, 19:55 #391586
Pelease, Can someone help me ?
Thanks!
healyhatman 9
March 11 2020, 00:46 #391587
In the switch just have the {fn:read_...} part
Then in your data provider do {var:read_dataoption1}|{var:read_dataoption2}|{var:read_dataoption3}
Give them the correct names of course
Doing that, it should use whichever read data actually has data.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
P
pdforest 20
March 15 2020, 13:54 #391631
Thanks gix.vax and healyhatman for your answer.
I put in the switch_read only the read functions:
/^36[0-6]$/:{fn:read_data1}
[div]/^36[7-9]$/:{fn:read_data2}
/^37[0-9]$/:{fn:read_data3}
[/div]
It works ok at this part but I want to have only 1 view, how do I know wich data reader was chosen?
I tried to implement a switch to the views: switch_view
/^36[0-6]$/:{view:datos_list1}
/^36[7-9]$/:{view:datos_list2}
/^37[0-9]$/:{view:datos_list3}
The view datos_list1 has {var:read_data1} as the data provider
The view datos_list2 has {var:read_data2} as the data provider
The view datos_list3 has {var:read_data3} as the data provider
The event:
{fn:switch_read}
{fn:switch_view}
But I can't make it work!
Do you know another way to do that?
healyhatman 9
March 15 2020, 20:35 #391632
You can put both things in the one switch
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
P
pdforest 20
March 18 2020, 18:24 #391670
I put both things in the one switch but the list table is not printed
4.png
1.png
2.png
3.png
Attachments
4.png
4.png
(14.63 KiB)
126 Downloads/Views
1.png
1.png
(13.07 KiB)
130 Downloads/Views
2.png
2.png
(19.57 KiB)
126 Downloads/Views
3.png
3.png
(33.83 KiB)
126 Downloads/Views
healyhatman 9
March 18 2020, 23:36 #391674
You have "return the result as var" turned on, which as the description says won't print. Turn it off.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
P
pdforest 20
March 20 2020, 14:22 #391701
Hi, thank you, turning off "return the result as var" works fine so at this point I can switch between data readers and viewers using a single switch.

But I still need some help because there are links in the view list table referencing to the row item that doesn't work:

Table column view:
Dato.Nombre:{view:dato_view_link}

and

dato_view_link Content:
{var:datos_list_table.row.Dato.Nombre}

dato_view_link Parameter:
dato_aid={var:datos_list_table.row.Dato.aid}

I don't want to have every link duplicated so I put a session var with the chosen view
I have the variable {session:alegria.dataviewer}

The question is how can I dynamically reference to the view item like this?:

dato_aid={var:{session:alegria.dataviewer}.row.Dato.aid}

But the above code doesn't work.
healyhatman 9
March 21 2020, 03:37 #391709
data_aid={session:alegria.dataviewer.row.Dato.aid}
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
P
pdforest 20
March 21 2020, 12:22 #391710
Sorry healyhatman but it doesn't work.
healyhatman 9
March 21 2020, 13:21 #391711
Use a {debug:} to see what data you have available
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
healyhatman 9
March 21 2020, 13:29 #391712
Why are you using {session:user.id} by the way, instead of just using {user:id} ?
And try just putting both data sources in the link. Like href="{var:source1whatever}{var:source2whatever}" since only one of them will actually have anything in it.
Could also move these things to their own event. So in your switch you could have {event:somethingsomething} and then you can put all your views and read datas in the event.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store