Skip to content

Commit e29be26

Browse files
Add setting to control display of representations on object summaries
1 parent 67b9091 commit e29be26

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

app/models/ca_bundle_displays.php

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* ----------------------------------------------------------------------
88
*
99
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
10-
* Copyright 2010-2024 Whirl-i-Gig
10+
* Copyright 2010-2025 Whirl-i-Gig
1111
*
1212
* For more information visit http://www.CollectiveAccess.org
1313
*
@@ -230,8 +230,24 @@ public function __construct($id=null, ?array $options=null) {
230230

231231
parent::__construct($id, $options);
232232

233+
$this->initSettings();
234+
}
235+
# ------------------------------------------------------
236+
/**
237+
*
238+
*/
239+
public function load($id=null, $use_cache=true) {
240+
$ret = parent::load($id, $use_cache);
241+
$this->initSettings();
242+
return $ret;
243+
}
244+
# ------------------------------------------------------
245+
/**
246+
*
247+
*/
248+
public function initSettings() {
233249
//
234-
$this->setAvailableSettings([
250+
$settings = [
235251
'show_empty_values' => [
236252
'formatType' => FT_NUMBER,
237253
'displayType' => DT_CHECKBOXES,
@@ -268,7 +284,25 @@ public function __construct($id=null, ?array $options=null) {
268284
'label' => _t('Show display in'),
269285
'description' => _t('Restrict display to use in specific contexts. If no contexts are selected the display will be shown in all contexts.')
270286
]
271-
]);
287+
];
288+
if((int)$this->get('table_num') === 57) {
289+
$settings['show_representations'] = [
290+
'formatType' => FT_TEXT,
291+
'displayType' => DT_SELECT,
292+
'width' => 4, 'height' => 1,
293+
'takesLocale' => false,
294+
'default' => 'all',
295+
'options' => [
296+
_t('No') => '',
297+
_t('All') => 'all',
298+
_t('Primary only') => 'primary'
299+
],
300+
'label' => _t('Display representations?'),
301+
'description' => _t('Display primary or all representations at top of display?')
302+
];
303+
}
304+
305+
$this->setAvailableSettings($settings);
272306
}
273307
# ------------------------------------------------------
274308
/**
@@ -345,7 +379,13 @@ public function set($pa_fields, $pm_value="", $options=null) {
345379
if ($pa_fields === 'table_num') { return false; }
346380
}
347381
}
348-
return parent::set($pa_fields, $pm_value, $options);
382+
383+
$ret = parent::set($pa_fields, $pm_value, $options);
384+
if((is_array($pa_fields) && isset($pa_fields['table_num'])) || ($oa_fields === 'table_num')) {
385+
$this->initSettings();
386+
}
387+
388+
return $ret;
349389
}
350390
# ------------------------------------------------------
351391
public function __destruct() {

themes/default/views/editor/objects/summary_html.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* ----------------------------------------------------------------------
88
*
99
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
10-
* Copyright 2010-2021 Whirl-i-Gig
10+
* Copyright 2010-2025 Whirl-i-Gig
1111
*
1212
* For more information visit http://www.CollectiveAccess.org
1313
*
@@ -30,7 +30,9 @@
3030

3131
$t_display = $this->getVar('t_display');
3232
$placements = $this->getVar("placements");
33-
$reps = $t_item->getRepresentations(array("thumbnail", "small", "medium"));
33+
34+
$show_reps = $t_display->getSetting('show_representations');
35+
$reps = (!in_array($show_reps, ['all', 'primary'], true)) ? [] : $t_item->getRepresentations(array("thumbnail", "small", "medium"), null, ['primaryOnly' => ($show_reps === 'primary')]);
3436
?>
3537
<div id="summary" style="clear: both;">
3638
<?php

0 commit comments

Comments
 (0)