Jump to content

Get page by title (which includes a pipe)


Recommended Posts

For an import script I need to match existing pages by page title, but some of the titles include a pipe. I cannot find a selector to get these pages. I have no idea what else to try.

$title = "test | test";
// Non of these selectors get my existing page:
pages()->get("template=edition, parent=3997, title=" . sanitizer()->selectorValue($title));
pages()->get("template=edition, parent=3997, title=$title");
pages()->get([
    'template' => 'edition',
    'parent'   => 3997,
    'title='   => sanitizer()->text($title),
]);

 

Link to comment
Share on other sites

What is with an options array that contains a blacklist without the pipe sign?

$options = [
    'blacklist' => [
			'"', "\\0", "\\", "`", '=', '*', '%', '~', '^', '$', '#',
			'<', '>', '[', ']', '{', '}', "\r", "\n", "\t"]
];
sanitizer()->selectorValue($title, $options);

 

Link to comment
Share on other sites

5 minutes ago, horst said:

What is with an options array that contains a blacklist without the pipe sign?

Or going the other way round, adding the pipe to the whitelist (and forcing quotes for it):

$ptions = [
	'whitelist' => ['|'],	// selectorValue() normally strips out pipe symbols, so allow them
	'quotelist' => ['|']	// Have selectorValue quote values that contain a pipe symbol
];

 

  • Like 3
Link to comment
Share on other sites

Thank you both, unfortunatelly I can't test your suggestions right now, because the site is still using PW 3.0.150, which doesn't has these options. Upgrading PW to the latest dev broke my site, so I had to return to the old version for now.

But I could solve my issue for now by quoting the value in the selector. After updating PW I will try your suggestions.

pages()->get("template=$templateName, parent=$parent, title=\"$value\"");

 

  • 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...