Modifying AllElementTexts.php

I am using Omeka Classic 2.7. I am experimenting with setting up a multi-lingual site and I was hoping to use the index parameter for the metadata function to pick which metadata field would display based on the locale. This works fine on the Browse Items page but the show Item page uses all_element_texts() to display all metadata. This in turn uses the AllElementTexts helper (in application/views/helpers). This function also uses the metadata function and by default uses the ‘all’ => true option, displaying all filled metadata fields and responds only to that parameter; ‘index’ => 1 displays no fields at all, just headers.

The line looks like this from AllElementTexts.php:

return $this->view->metadata($record, $metadata, array('all'=>true);


return $this->view->metadata($record, $metadata, array('index'=>1);

returns no values.

Any ideas?



I’m not looking at it right now, but all returns an array while index returns a single value. Perhaps you just need to wrap your version in an array?

Thanks John. That did the trick in one way. It now shows just the indexed metadata field but it also ignores the show_empty_elements option and shows all fields whether filled or not. At least now it’s working in a way I go into the code and try to figure out why show_empty_elements option is not working.

Thanks again,


In case any one is interested in how this works, here’s the first draft of code in AllElementTexts:

    protected function _getFormattedElementTexts($record, $metadata)
	   $currentLocale = Zend_Registry::get('bootstrap')->getResource('Locale')->toString(); 
	   if (locale_description($currentLocale)=='中文 - 中国'): 
        return array($this->view->metadata($record, $metadata, $opt));

I need a more sophisticated way to handle the locale selection and we will need to stay disciplined in how we use the multiple metadata fields. And not quite clear how we want to handle the admin side which uses the same helper.


Perhaps you’d be better off making your change in common/record-metadata.php instead, the view used to render the “all element texts” output.

Rather than modifying the array that’s getting passed into that view, you could change the view to just grab the appropriate value out of the full array.

With overriding a view in a theme, it will automatically take care of keeping the admin side unaffected (plus insulate you from core updates).

Good idea. I was thinking about where to finally put this code to get it into a safe place. Thanks.