OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Site level Plugins and blocks

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Site level Plugins and blocks

Postby imtechnology » Sun Jul 01, 2012 2:41 am

It seems to me that many of the options for the site level of the OJS install (especially the plugins and custom blocks) are disabled / not available. Why is this?

So much work has gone into providing this functionality for the individual journal that it seems silly to me for them not to be available at the main site level.

The site level page is the very first this that people see when they visit a domain hosting several journals and to have such limited functionality and options seems a little silly to me.

Specifically it would be important to have the ability to include the "static pages" plugin as well as the "google analytics" plugin available by default.

But enabling a plugin system (and also the blocks functionality) would also allow for better customization to the site level content and for new plugin development.

For instance, given the opportunity the first custom block I would develop would be one which show the latest volumes published site wide.
imtechnology
 
Posts: 14
Joined: Sat Jun 23, 2012 6:46 pm

Re: Site level Plugins and blocks

Postby asmecher » Wed Jul 04, 2012 10:42 am

Hi Ed,

I've followed up on the similar issue at http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=3930. The current work-around for customizing block plugin layout is to modify it directly in the database (and make sure you flush your data caches after you do that or else you won't see any changes). Note that since site-wide block plugin controls haven't been available many of the block plugins haven't been written with site-wide context in mind, i.e. they probably won't expect to be used outside the journal context. However, corrections for that should be straight-forward.

As I mentioned on the bug entry, we've done a lot of UI work for OMP and that includes the block management tools; this work will eventually be back-ported to OJS and that will resolve this issue.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9063
Joined: Wed Aug 10, 2005 12:56 pm

Re: Site level Plugins and blocks

Postby imtechnology » Fri Jul 06, 2012 5:23 am

Hi Alec!

Thanks for taking the time to reply. So I have tried to follow your suggestions and I am now able to generate new pages that are able to display at site level. BUT, I am now having a problem working out how to add links to the navbar only at the site level.

Alec, are you able to provide some guidance on how I can add an additional item to the site level navbar?

Also, for the benefit of others I thought I would post a step by step guide below on how to add static pages at site level.

BUT,
For this to work there is an issue that I was wondering if the programming team could add a patch for. It can be corrected manually but it would be better to include it in the main code for future updates. It is as follows.

In the file StaticPagesHandler.inc.php the following line needs to change from:
Line 30
Code: Select all
      $journalId = $journal->getId();


to

Code: Select all
      $journalId = $journal?$journal->getId():0;


without this change you get the following error:
Code: Select all
Fatal error: Call to a member function getId () on a non-object


Once this change has been made the following sql statements need to be made:
[apologies for the terrible explination for sql I am not very good at that.]

SQL statement 1
Code: Select all
INSERT INTO `plugin_settings` (`plugin_name`, `locale`, `journal_id`, `setting_name`, `setting_value`, `setting_type`) VALUES
('staticpagesplugin', '', 0, 'enabled', '1', 'bool');


SQL statement 2
Code: Select all
INSERT INTO `static_pages` (`static_page_id`, `path`, `journal_id`) VALUES
(AUTO_INCREMENT, 'PATH', 0);

where PATH is equal to the path you want for the page, and AUTO_INCREMENT equlas the next ID value.

SQL statement 3
Code: Select all
INSERT INTO `static_page_settings` (`static_page_id`, `locale`, `setting_name`, `setting_value`, `setting_type`) VALUES
(static_page_id, 'en_US', 'content', 'PAGE_TEXT', 'string'),
(static_page_id, 'en_US', 'title', 'PAGE TITLE', 'string');

where static_page_id is the same as the AUTO_INCREMENT value in SQL statement 2. PAGE TITLE is the title of the page you are creating and PAGE_TEXT is the text that you want to appear on the page.

Pages can then be accessed by going to:
Code: Select all
http://www.site.com/pages/view/%PATH%

where %PATH% equals the PATH value in SQL statement 2.

Now the problem is working out how to add a link to this page to the site level navbar only. Any help really appreciated.

Cheers,
Ed.
imtechnology
 
Posts: 14
Joined: Sat Jun 23, 2012 6:46 pm

Re: Site level Plugins and blocks

Postby asmecher » Fri Jul 06, 2012 9:38 am

Hi Ed,

Thanks for posting those detailed instructions; they're sure to come in useful to others. I've committed the change you suggested (see http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=7670) and this will come out with our next OJS release.

Meanwhile, the navbar can't be done with just a database change. There are a few options here:
  • Modify the navbar template directly, if you want the same change to apply to *all pages*, regardless of whether they are journal-level or site-level. To do this, add your link in templates/common/navbar.tpl.
  • Modify the TemplateManager to supply a navbar structure for the site level only. To do this, edit classes/template/TemplateManager.inc.php. You can see where the value is fetched for the journal context:
    Code: Select all
    // Assign additional navigation bar items
    $navMenuItems =& $journal->getLocalizedSetting('navItems');
    $this->assign_by_ref('navMenuItems', $navMenuItems);
    As you can see, this takes place within a conditional that checks to make sure a journal exists for this request:
    Code: Select all
    if (isset($journal)) {
    If you look further down, you'll see the "else" condition for this conditional:
    Code: Select all
    } else {
    Here you can put something to fix your navbar for the site context, e.g.:
    Code: Select all
    $this->assign('navMenuItems', array(array('name' => 'the name', 'url' => 'the url', 'isLiteral' => true, 'isAbsolute' => true)));
    "isLiteral" refers to whether or not you'll be using a locale key (which is translated from the XML language files) or a literal string (which will be used directly). "isAbsolute" should be true for a fully-qualified URL.
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9063
Joined: Wed Aug 10, 2005 12:56 pm

Re: Site level Plugins and blocks

Postby imtechnology » Mon Jul 09, 2012 4:51 am

Thanks Alec!

Worked a treat!!!

Any chance you could help me on my next problem?

viewtopic.php?f=8&t=8819
imtechnology
 
Posts: 14
Joined: Sat Jun 23, 2012 6:46 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest