Forums

set var and loop function doubt

emmexx 24 Oct, 2018
I'm not sure I'm using some of the ccv6 features correctly.

Loop function
I believed the difference between the repeater view and the loop function had something to do with an MVC pattern but the loop function seems to output everything unless you put the result in a var.
What's the difference between the two?

var.set
I put the following code in a php function (myphp):
$tmp = $this->get('gOutside', [li]);
$tmp[/li] = ("aField" = 45);[br]$this->set('gOutside', $tmp);
I put this function in a loop function (myloop).
I create an event with content:
{fn:myloop}
{debug:}
I expect to find gOutside in the output of the debug function but it is not there.

I change the event to:
{fn:myloop}
{var/pr:gOutside}
and the content of gOutside is displayed.
Why is that?

I chenge the content of the event to:
{var.set:foo$(val:3)}
{debug:}
but foo is not there to be seen.

I want to use gOutside as a provider of another function but it's not working. I also tried creating another php function that return gOutside but that too is empty for other functions [EDIT: I can't reproduce this, now it seems to work, it could be because now the loop is set to return the result as var].
I am missing something but what is it?

Thank you
maxx
healyhatman 25 Oct, 2018
Well yes if you don't set it to return as a var, it won't return as a var - it will print it.
emmexx 29 Oct, 2018

Well yes if you don't set it to return as a var, it won't return as a var - it will print it.


I'm not sure that is the actual behaviour. Or I'm using the loop the wrong way.

Other code that is not working as I expect:

In the loop body I put
{fn:ret_a_string}
The loop is set to return as var.

ret_a_string is a php function that... returns a string or echoes a string:
echo "test string";
return "test string";
The debug output as no info about the loop. Where is the loop var value?

I found another problem:
in the loop body field the var.set or data.set is not working with other var values:
{data.set:myfield$(var:myvar)}
I had to use a php function instead and set the data value there.

maxx
This topic is locked and no more replies can be posted.