Custom block Plugins

Hi,
I am using ojs_3_1_1_4 with more than 100 journals.
I would like to lock only this 3 blockPlugins always on the same position.

I have some plugins with a particular order in my sidebar, do you know if can I lock this plugins in all my journals? Could be reserved or locked order ??

Can I insert my plugins hardcode ? on this file BlockPluginsListbuilderHandler ?
example:
{call_hook name="…"}

Regards.
xavi

Hi @xavi,

Besides manually making a correct order from a dashboard for every journal, all else that I can think of requires code modifications. The easiest way would be to change styling with applying flex box where you can order flex items, like

.pkp_structure_sidebar {
  display: flex;
}
.block_make_submission {
  order: 1;
}
.block_information {
  order: 2;
}

In this case if those blocks are assigned by the user, they always will be displayed in your custom order.
Is this considered enough for your case?

Hi @Vitaliy,
Where do I have to put this code? in BlockPluginsListbuilderHandler ?

Could be possible if I modify the code on function setListsData($request, $filter) {

else switch ($plugins[$key]->getBlockContext()) {
				case BLOCK_CONTEXT_SIDEBAR:
					$sidebarBlockPlugins[$key] = $plugins[$key];
					break;
			}

Regards,
xavi.

Those are simple CSS rules, they can be added, e.g., from a dashboard. If it’s possible, I would recommend avoiding any changes in core files for the sake of future support.

Regarding the mentioned handler, as far as I see it’s used for settings form, not for displaying blocks on the front-end.

Hi @Vitaliy & @NateWr
I found this file:
lib/pkp/templates/controllers/tab/settings/appearance/form/sidebar.tpl

You can visit on Github:

Can you fix always this block plugins ?
I am not sure how can I order my block plugins on this template…

Which template I need to override to fix my block plugins (language, keywordCloud,…) ?

Best regards,
xavi.

Hi @xavi,
This is template for dashboard.
On the front-end every plugin has own. You can find them inside templates directory of a correspondent plugin, they are exposed through this hook with call_hook method: https://github.com/pkp/pkp-lib/blob/master/templates/frontend/components/footer.tpl#L19
This method is assigned to Smarty here and here.

Also, in OJS 3.1.1 you can manipulate by block plugin’s sequence from BlockPlugin class. Take a look here and here. But be aware that I cannot find these lines of code on the current master branch.

Hi @Vitaliy & @NateWr
I would like to modify order on my template: I attached an image to show you:

I would like:
The first always Language Toggle Block (or blocked )
The second always keyword Cloud Block (or blocked )

If any user change position, on the front always display my order and never disabled this plugins.

Regards,
xavi

HI @xavi,

I would recommend that you just output the blocks exactly where you want directly in the template files in your theme. You can get all block plugins, check their class, and output their HTML like this:

$blockPlugins = PluginRegistry::getPlugins('blocks');
foreach ($blockPlugins as $blockPlugin) {
  if (is_a($blockPlugin, ...)) {
    echo $blockPlugin->getContents($templateMgr);
  }
}

Perfect !!!
It resolved my problem, thanks a lot !!

Regards,
xavi.

Hi @NateWr,
I am using ojs 3_1_1 and my theme is bootstrap3.
I created structure on my theme:
ojs/plugins/themes/bootstrap3/templates/controllers/tab/settings/appearance/form/sidebar.tpl
Any change on this template it’s not loading.
I clean cached but it’s not working.

I can change code on this template and it’s working properly.
ojs/lib/pkp/templates/controllers/tab/settings/appearance/form/sidebar.tpl

Do you know if I need to do something special when the templates are on lib/pkp ?? I dont’t think so, but I am not 100%

Regards,
xavi

Do you know if I need to do something special when the templates are on lib/pkp ?? I dont’t think so, but I am not 100%

It should work fine, but it is possible that the template is called with a core: prefix that bypasses other templates. I’d recommend finding where in the code the sidebar.tpl template is being loaded.