Jump to content

Recommended Posts

Posted

Hi

If we use chinese text in processwire find method like the below the error appears as 'Fatal error: Exception: Unknown Selector operator: ''' 

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find("title={$title}");    
 

Could you please suggest on this. Thanks

 

Posted

Thanks for your reply

if we give

$title="School Resumes";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find("title={$title}");

echo $findeventspage;

this displays id 

if we give

$title="School Resumes";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find('title={$title}');

echo $findeventspage;

this does not displays id 

if we give

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find('title={$title}');

echo $findeventspage;

this also does not displays id. Actually we need to check the duplicates if availabe. 

Could you please suggest. Thanks

 

Posted
$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$findeventspage=$eventspage->events->find("title='$title'");

Try this

Posted

It is better to use $sanitizer->selectorValue() to get the value in the correct shape to be used in a selector than to add quotes yourself, though @Zeka's example works.

$title="谢师宴 11am-1pm, Test服务奖 service award";
$eventspage = $pages->get(1085); //eventspage
$selector = "title=" . $sanitizer->selectorValue($title);
$findeventspage=$eventspage->events->findOne($selector);

If a hand coded selector doesn't yield any results, it's always worth checking whether the PHP file is in the correct encoding (UTF-8). Access restrictions may also come into play, which can be easily checked by appending ", include=all" to the selector to ignore access checks.

Posted

@BitPoet Before posting my answer I have made tests with and without using $sanitizer->selectorValue. In this exact case, the page wasn't found after sanitizing of the string  "谢师宴 11am-1pm, Test服务奖 service award".

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
  • Recently Browsing   0 members

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