Jump to content

PageArray in selector (solved)


mel47
 Share

Recommended Posts

Hi,

I'm searching, without success, to use all values of the pageArray inside a selector : 

 foreach($page->alias as $al) {
	$publis = $pages->find("template=publication, categ_publi=$c, author.title={$page->title}|{$al->title}")
}

it doesn't work, but I have no idea how to get it.

Thanks

Link to comment
Share on other sites

Sorry, I should have remove this selector, since it's not the point.

Author is a PageReference field found on publication template. The field alias is a PageReference field from the template member. I want to be able to select publications for an author either by its name ($page->title) or from their alias (author could have 2 or 3 differents surnames; $page->alias). I know how to use a foreach to get a single page, but how to apply in case of a selector?

	$publis = $pages->find("template=publication, author.title=??")

Digging around while writing this explanation, I found this
 

	$publis = $pages->find("template=publication, author.id={$page->alias})  //works ->33 pages
	$publis = $pages->find("template=publication, author.title={$page->title}) //works ->82 pages
//but how come this doesn't work ->0page
	$publis = $pages->find("template=publication, author.id={$page->alias}, author.title={$page->title})

How I can combine both results in one selector?

Link to comment
Share on other sites

I am not sure I follow either but I'll have a go :).

  1. Is $page->alias a string or an integer? I am curious since you do this: author.id=$page->alias. Did you create your own field called id or is that the inbuilt page ID?
  2. I don't understand the foreach question. If what you are after is matching multiple values or multiple fields, then what we use are pipes |. See this docs.
  3. You say you would like to match publications by either name or their alias. However, the examples you give are not using or selectors; they are using AND selectors (i.e. comma separated selectors). See those docs for the differences.
  • Like 1
Link to comment
Share on other sites

7 hours ago, mel47 said:

I'm searching, without success, to use all values of the pageArray inside a selector : 


 foreach($page->alias as $al) {
	$publis = $pages->find("template=publication, categ_publi=$c, author.title={$page->title}|{$al->title}")
}

it doesn't work, but I have no idea how to get it.

You could do this as follows:

$titles = $page->alias->implode('|', 'title', array('append' => '|'));
$titles .= $page->title;
$publis = $pages->find("template=publication, categ_publi=$c, author.title=$titles");

 

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...