Jump to content

Repeater field access unformated multi language value


joeck
 Share

Recommended Posts

Hi,

I'm facing the issue where i have a repeater field with a multi language textarea (german & english, german beeing default). In german more blocks should be displayed as in english.
The textarea field is configured as inherit default language if blank (I don't want to change this since it is the wanted behaviour for all other pages...).

Now I want to access the unformatted value of the textarea field in the repeater and only show it if it is not empty. Something like this:

$body = "";
$page->of(false);
foreach($page->blocks as $block){ //blocks is repeater field, each block has title and textarea
    if ($block->textarea->getLanguageValue($user->language)){
        $body .= <<<EOD
            <div>
                <div class='uk-card uk-card-default uk-card-body'>
                    <h3 class='uk-card-title'>$block->title</h3>
                    $block->textarea
                </div>
            </div>
EOD;
    }
}
$page->of(true);
print $body;

However this doesn't work: Call to a member function getLanguageValue() on string.

I also tried the other syntax for getLanguageValue:

$page->getLanguageValue($language, $field)

But I didn't manage to get a unique name of the textarea field in the repeater.

I looked into the API of FieltypeRepeater but couldn't find anyhting that fixed my issue.

Any ideas?

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

×
×
  • Create New...