$this->pages('templates^=shop_product');
currently?
Operator '^=' is not yet supported for fields native to pages table
Started by Oliver, Feb 20 2012 05:10 PM
7 replies to this topic
#1
Posted 20 February 2012 - 05:10 PM
Not yet? Will it be supported? Is there any way to do something like
#2
Posted 20 February 2012 - 05:20 PM
ah get it.
@somartist - wire("soma")->is("creative|coder")->say("hello");
#3
Posted 20 February 2012 - 05:30 PM
You could do something like this:
more likely...
Fun.
$tpl = $templates->find('name^=basic-')->first();
$pa = $pages->find("template=$tpl");
more likely...
$pa = new PageArray();
$tpl = $templates->find('name^=basic-');
foreach($tpl as $tp) {
$pa->import( $pages->find("template=$tp") );
}
Fun.
@somartist - wire("soma")->is("creative|coder")->say("hello");
#4
Posted 20 February 2012 - 05:47 PM
$pa = $pages->find('template=' . implode('|', $templates->find('name^=basic-')));
#5
Posted 20 February 2012 - 06:03 PM
As usual: too simple. Thanks ryan.
#6
Posted 20 February 2012 - 06:04 PM
I've left that to you Ryan... was going to put it but thought someone else will 
BTW why can't this work? with 12,32,42,42 instead of |, would be even shorter ?
EDIT: Problem is it doesn't seem to work for me here. ?
EDIT: Ok got it
This is the right one:
BTW why can't this work? with 12,32,42,42 instead of |, would be even shorter ?
$pa = $pages->find('template=' . $templates->find('name^=basic-')); EDIT: Problem is it doesn't seem to work for me here. ?
EDIT: Ok got it
This is the right one:
$pa = $pages->find("template=" . implode("|", $templates->find('name^=basic-')->getArray()));
@somartist - wire("soma")->is("creative|coder")->say("hello");
#7
Posted 20 February 2012 - 06:32 PM
Comma can't be used to separate the template names because comma is used to separate individual components of a selector. However, the default output of WireArray::__toString isn't really that useful at present, so I've modified it to return a selector compatible string instead (like PageArray does). So if you've got the latest commit, you can do this (copied from your example):
$pa = $pages->find('template=' . $templates->find('name^=basic-'));
#8
Posted 20 February 2012 - 06:39 PM
Great thanks Ryan! The shorter the better.
@somartist - wire("soma")->is("creative|coder")->say("hello");
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












