Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit: I did some more digging and found out how to do this. You need to call "disable_locale_filter" before you get your SiteTree objects:</strong></p> <pre><code>Translatable::disable_locale_filter(); </code></pre> <p>Then call "enable_locale_filter" once you've retrieved them:</p> <pre><code>Translatable::enable_locale_filter(); </code></pre> <hr> <p><strong>These are other approaches which I'll leave here as I think they are still useful...</strong></p> <p>I believe you may have to do this using Translatable::get_by_locale() - I assume you only want people to be able to select a page to link to within their language??</p> <p>Perhaps something like this? </p> <pre><code>public function getCMSFields_forPopup() { $member = Member::currentUser(); if($member &amp;&amp; $member-&gt;Locale) { $pagesByLocale = Translatable::get_by_locale('SiteTree', $member-&gt;Locale); $pagesByLocale = $pagesByLocale-&gt;map('ID', 'Title', '(Select one)', true); return new FieldSet( new TextField('Title'), new TextField('URL', 'Externer Link'), new DropdownField('PageLinkID', 'Interner Link', $pagesByLocale); ); } else { // Handle non-member } } </code></pre> <p>Edit: see comments below but another option is to use the Translatable::get_current_locale() function to find all pages in the Site Tree for that locale... if the user is viewing an english page then the locale should be set to english etc...</p> <pre><code>public function getCMSFields_forPopup() { $pagesByLocale = Translatable::get_by_locale('SiteTree', Translatable::get_current_locale()); $pagesByLocale = $pagesByLocale-&gt;map('ID', 'Title', '(Select one)', true); return new FieldSet( new TextField('Title'), new TextField('URL', 'Externer Link'), new DropdownField('PageLinkID', 'Interner Link', $pagesByLocale); ); } </code></pre> <p>You can also get the locale from the current page e.g.</p> <pre><code>$this-&gt;Locale; // From within the model $this-&gt;dataRecord-&gt;Locale; // from within the controller Director::get_current_page()-&gt;Locale; // If you're outside the context of the page altogether i.e. code inside your DataObject. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload