Dear all
back in OJS 3.3 I used to retrieve custom additional data directly in the template file of my theme, e.g.:
<p>...{$issue->getData('GTIN_print')}...</p>
In this case the data is in the table issue_settings
:
+----------+--------+---------------+----------------+--------------+
| issue_id | locale | setting_name | setting_value | setting_type |
+----------+--------+---------------+----------------+--------------+
| 126 | | GTIN_print | 9783039781478 | string |
+----------+--------+---------------+----------------+--------------+
In OJS 3.4 this is not as simple any more. Can some of you please help, how to get custom data from the db without creating an additional plugin, and by just modifying within the theme?
I guess it would be necessary to append the $collector
of $issue
in advance.
I’ve got this in a function of my template’s php:
$issue = Repo::issue()->getCollector()
->filterByContextIds([$journal->getId()])
->filterByIssueIds([$issue->getId()])
->getMany($collector)
->map(function($issue) {
// Fetch GTIN_print_id from the issue_settings table
$GTIN_print_id_result = DB::select("SELECT setting_value FROM issue_settings WHERE issue_id = ? AND setting_name = 'GTIN_print_id'", [$issue->getId()]);
// Attach GTIN_print_id to the issue data
if (!empty($GTIN_print_id_result)) {
$issue->setData('GTIN_print_id', $GTIN_print_id_result[0]->setting_value);
}
error_log('$GTIN_print_id_result is: ' . $GTIN_print_id_result);
return $issue;
});
Of course it’s not working at all and I hope that is a less complicated way to do this
Looking forward to seeing some of you in Turin next week.
All the best
Klaus