Harmster Posted May 30, 2013 Share Posted May 30, 2013 Hey. I've got a template with a statistics repeater field the repeater field contains 4 fields -statistics --stat_type --data_version --value --future_data In the same template there's also a field called game_id. When I use the following selector I get a page back but I can't access the value: $pages->get("statistics.stat_type=ITEM1, game_id=877760255"); I've used the Selector module and it returned 2 pages, but thats because it uses find. How can i access the value field? Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Share Posted May 30, 2013 I think theres possibly some inconsistent behavior with get and find when using more sophisticated selectors. Just use a find with a limit =1 and a first () chained. Link to comment Share on other sites More sharing options...
Harmster Posted May 31, 2013 Author Share Posted May 31, 2013 I've tried it but still the same result... Any other ideas? Link to comment Share on other sites More sharing options...
Wanze Posted May 31, 2013 Share Posted May 31, 2013 When I use the following selector I get a page back but I can't access the value: Which value? Link to comment Share on other sites More sharing options...
Harmster Posted May 31, 2013 Author Share Posted May 31, 2013 This value: -statistics --stat_type --data_version --value Link to comment Share on other sites More sharing options...
Wanze Posted May 31, 2013 Share Posted May 31, 2013 So you tried something like this: $p = $pages->get("statistics.stat_type=ITEM1, game_id=877760255"); // First value $value = $p->statistics->first()->value; Can you post your code? If you have the page, then statistics still contains all the pages with different ITEMs I guess. Link to comment Share on other sites More sharing options...
Harmster Posted May 31, 2013 Author Share Posted May 31, 2013 Error: Exception: Method Page::first does not exist or is not callable in this context (in C:\wamp\www\social\wire\core\Wire.php line 232)Thats the result Wanze. Thats what I expected since var_dump returns NULL... So theres no array or object returned... This is how I make the repeater values: foreach($match->statistics->array as $statistic){ $s = $p->statistics->getNew(); $s->stat_type = $statistic->statType; $s->data_version = $statistic->dataVersion; $s->value = $statistic->value; $s->future_data = $statistic->futureData; $s->save(); } And this is how i try to get the items: for($i=1;$i<7;$i++){ $item = $this->pages->find("statistics.stat_type=ITEM" . $i . ", game_id=$match->game_id, limit=1"); if($item->id){ $item1 = $item->first(); $this->html .= $item1->value; } } Also tried: for($i=1;$i<7;$i++){ $item = $this->pages->get("statistics.stat_type=ITEM" . $i . ", game_id=$match->game_id, limit=1"); if($item->id){ $item1 = $item->first(); $this->html .= $item1->value; } } Or: for($i=1;$i<7;$i++){ $item = $this->pages->find("statistics.stat_type=ITEM" . $i . ", game_id=$match->game_id, limit=1"); if($item->id){ $val= $item->first()->value; $this->html .= $val; } } Link to comment Share on other sites More sharing options...
Wanze Posted May 31, 2013 Share Posted May 31, 2013 $item = $this->pages->get("statistics.stat_type=ITEM" . $i . ", game_id=$match->game_id, limit=1"); if($item->id){ $item1 = $item->first(); $this->html .= $item1->value; } $item is the page containing the repeater, not the repeater itself. Your value field is in the pages inside the repeater: $statistics = $item->statistics; foreach ($statistics as $stat) { // Value is a field in the repeater echo $stat->value; } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now