Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to Disable Translatable on Search Results


Go to End


6 Posts   1880 Views

Avatar
Tama

Community Member, 138 Posts

28 September 2012 at 11:14am

Edited: 28/09/2012 11:15am

We are running SS3 with Translatable.

If a search term is entered the following page comes up:
http://localhost.devsite/home/SearchForm?Search=book&action_results=Go

With the following error:

[Notice] Undefined property: Page::$Locale
GET /home/SearchForm?Search=book&action_results=Go
Line 542 in C:\source\devsite\translatable\code\model\Translatable.php

The Source shown is:

533 	 * It falls back to "Locale='' OR Lang IS NULL" and assumes that
534 	 * this implies querying for the default language.
535 	 * 
536 	 * Use {@link disable_locale_filter()} to temporarily disable this "auto-filtering".
537 	 */
538 	function augmentSQL(SQLQuery &$query) {
539 		// If the record is saved (and not a singleton), and has a locale,
540 		// limit the current call to its locale. This fixes a lot of problems
541 		// with other extensions like Versioned
542 		$locale = ($this->owner->ID && $this->owner->Locale) ? $this->owner->Locale : Translatable::get_current_locale();
543 		$baseTable = ClassInfo::baseDataClass($this->owner->class);
544 		if(
545 			$locale
546 			// unless the filter has been temporarily disabled
547 			&& self::locale_filter_enabled()
548 			// DataObject::get_by_id() should work independently of language

Line 536 suggests that this can be disabled, but I don't know how.

Any suggestions would be appreciated.

Avatar
rcurry

Community Member, 1 Post

1 October 2012 at 1:30pm

Hi Tama,

If you update your version of Translatable it should fix this problem. The Locale variable wasn't being checked for properly so it would always crash when it found an object without it.

Avatar
Tama

Community Member, 138 Posts

2 October 2012 at 9:20am

Cheers Robert

Avatar
sashion

Community Member, 25 Posts

5 December 2012 at 6:29am

Edited: 05/12/2012 6:29am

Hey,

I got the same error. Updating didn´t solve the problem...
@Tama: Did this solve yours?

Cheers,
Sash

Avatar
Tama

Community Member, 138 Posts

6 December 2012 at 12:43pm

Hi Sash

Yes, updating solved the problem for us.

Cheers
Tama

Avatar
elgordo

Community Member, 70 Posts

10 May 2013 at 12:55pm

This commit resolved the issue for me

https://github.com/silverstripe/silverstripe-translatable/pull/39

Cheers

Gordon