ojs : 3 options for inserting content into existing template
Trying to insert into the editor/createIssue page (for example) something that will
1) display the journal's openreview policy
2) display controls for setting the issueOpenReviewPref, writing that to DB and reading it from DB for correct setting on reload of page
Proving extremely difficult. There are no hooks, so I can't use the preferred method. I really, really don't want to modify the base files, so that leaves me with Smarty postfilters, and after a couple of hours of experimenting, I can't figure out where code like that shown in the example is supposed to go (the docs say just "include code like this in your application").
AS posted this on the forum at
https://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=10134&p=39406&hilit=template+insert+content#p39406
code a GenericPlugin that uses hooks directly to add content but that depends on a hook appearing precisely where you need it.
If no hook appears precisely where you need it in the template, the situation becomes more difficult. You have two options OTOH:
1) Modify the template to include a new hook. This will somewhat taint your plugin, as it'll require a modification to apply, but the modification will be simple and clean.
2) Use a Smarty postfilter to filter the footer template's output with string manipulation functions, and insert the markup you want to add at the correct place. This will be somewhat brittle (if the footer markup changes, it may throw your plugin off) but it won't require modification to the system.
Example of Smarty postfilter (which doesn't provide context on _where_ to include this kind of code) at http://www.smarty.net/docs/en/advanced.features.postfilters.tpl
<?php
// put this in your application
function add_header_comment($tpl_source, Smarty_Internal_Template $template)
{
return "<?php echo \"<!-- Created by Smarty! -->\n\"; ?>\n".$tpl_source;
}
// register the postfilter
$smarty->registerFilter('post','add_header_comment');
$smarty->display('index.tpl');
?>
The postfilter above will make the compiled Smarty template index.tpl look like:
<!-- Created by Smarty! -->
{* rest of template content... *}