Jump to content


Photo

Operator '^=' is not yet supported for fields native to pages table


  • Please log in to reply
7 replies to this topic

#1 Oliver

Oliver

    Sr. Member

  • Members
  • PipPipPipPip
  • 133 posts
  • 25

  • LocationBasel, Switzerland

Posted 20 February 2012 - 05:10 PM

Not yet? Will it be supported? Is there any way to do something like
$this->pages('templates^=shop_product');
currently?

#2 Soma

Soma

    Hero Member

  • Moderators
  • 3,421 posts
  • 1944

  • LocationSH, Switzerland

Posted 20 February 2012 - 05:20 PM

Don't know what you mean by for fields native?

ah get it. :D

@somartist | modules created | support me, flattr my work flattr.com


#3 Soma

Soma

    Hero Member

  • Moderators
  • 3,421 posts
  • 1944

  • LocationSH, Switzerland

Posted 20 February 2012 - 05:30 PM

You could do something like this:


$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 | modules created | support me, flattr my work flattr.com


#4 ryan

ryan

    Hero Member

  • Administrators
  • 5,985 posts
  • 3387

  • LocationAtlanta, GA

Posted 20 February 2012 - 05:47 PM

$pa = $pages->find('template=' . implode('|', $templates->find('name^=basic-')));

:)

#5 Oliver

Oliver

    Sr. Member

  • Members
  • PipPipPipPip
  • 133 posts
  • 25

  • LocationBasel, Switzerland

Posted 20 February 2012 - 06:03 PM

As usual: too simple. Thanks ryan. ;)

#6 Soma

Soma

    Hero Member

  • Moderators
  • 3,421 posts
  • 1944

  • LocationSH, Switzerland

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 ? :D


$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 | modules created | support me, flattr my work flattr.com


#7 ryan

ryan

    Hero Member

  • Administrators
  • 5,985 posts
  • 3387

  • LocationAtlanta, GA

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 Soma

Soma

    Hero Member

  • Moderators
  • 3,421 posts
  • 1944

  • LocationSH, Switzerland

Posted 20 February 2012 - 06:39 PM

Great thanks Ryan! The shorter the better. :D

@somartist | modules created | support me, flattr my work flattr.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users