Editing story item type and theme display

Hi There,

I have a couple of things I’d like to change in the story item type and the way it is styled by Curatescape.

Firstly, what would I change if I wanted to add an additional field to stories (I’m assuming this would involve editing php) - e.g. another story field identical to the English story field except that it draws on a different metadata attribute added to the Curatescape Story item type. So Story attribute > Story displayed in CSS, Story (Welsh) > Another identically styled story block below the first styled in CSS. Is there any way I can make those expandable and collapsible?

Secondly, what would I need to change to make the labelled fields bilingual. I.e. leave what is in the tags the same, but change the text labelling the field as ‘Tags:’ to read ‘Tags | Tagiau:’

We’re exploring different experimental options for bilingualism still and I’m learning a lot, but any help would be great.

All the best,

Hi @james-smith,

This could be a somewhat complicated issue, depending on your prior coding experience. But the first step is relatively straightforward – though not without some challenges – so I would recommend starting by translating static labels.

1. Translating labels

The translation process is outlined in the Omeka documentation. You will need to generate translations for any static labels that are not already covered. Anywhere you see a string in the code like __('Tags') (with two underscores preceding quoted text in parenthesis), that string can be automatically updated to the Welsh equivalent if it is already in the .po/.mo translation files. A user should automatically see Tagiau instead of Tags if they have Welsh set as their language of choice (either in the browser or via a language-switching plugin).

In the case of strings like “Tags,” “Items,” etc, those should already be translated to Welsh and work without further change (since, I think, Omeka ships with a basic Welsh translation), but you’ll need to add ones that are unique to the Curatescape theme (e.g. “View a random story,” “Tour,” etc.).

NOTE: Before getting into more complicated changes, I should point out that manually editing the theme will impact your ability to get updates going forward. You will essentially be taking on the task of maintaining your own theme since any future updates will overwrite your changes.

That said, here are some pointers:

2. Adding a new field

You can edit item types at /admin/item-types. There you could add a field like Story (Welsh) to the Curatescape Story item type.

3. Displaying a new field

The story text is generated using a function called mh_the_text(), which you can see in the custom.php file at line 915:

(That function currently uses the Dublin Core Description as a fallback if there is no value for the Story field, but that is a legacy functionality that will be removed so you can ignore it.)

To show both English and Welsh versions at once, you could update that function to something like this (assuming your new field is called “Story (Welsh)”):

function mh_the_text($item='item',$options=array()){
    $welsh_text = element_exists('Item Type Metadata','Story (Welsh)') ? '<div class="welsh">'.metadata($item,array('Item Type Metadata', 'Story (Welsh)'),$options).'</div>' : null;
    $primary_text = element_exists('Item Type Metadata','Story') ? '<div class="english">'.metadata($item,array('Item Type Metadata', 'Story'),$options).'</div>' : null;
	return $primary_text ? replace_br($primary_text.$welsh_text) : null;

Your implementation may vary depending on how your language-switching plugin works and what you have in mind for the user experience.

You would also need to do something similar in several other functions, including for the title, subtitle, lede, etc. All those functions can be found in the custom.php file and are implemented throughout the theme, including in items/show-template-default.php, among many others.

4. Styling the new field

You’ll need to use CSS to modify how (and possibly when) the new fields appear to the user (i.e. when they have a particular language set, you may want to hide/show the English/Welsh). The details will depend again on your preferences as well as how the language-switching plugin works. To add something like a toggle, you’d probably want to use JavaScript.

5. Other

You will likely find some areas that cannot be translated using the methods above. These would include any strings that are generated using JavaScript (e.g. the slide out menu, the map marker popups, etc). Those would need to be handled on a case by case basis and would likely involve using a combination of PHP, JavaScript, HTML, and CSS.

Thanks again Erin. We’re just trying to find a formula that works for us and exploring our options. Those options are very helpful.