OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Creating a Block

OCS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, michael

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Re: Creating a Block

Postby spatialguru » Wed Jun 18, 2008 10:55 am

Here's a screenshot as an example of how this looks. Note that the first three sponsors have a logo, but one does not (due to being a lower level sponsor). The code mentioned in this thread will insert the URL instead of the logo if there is no logo defined.

sponsorsblock.jpg
Sponsors Block Plugin example
sponsorsblock.jpg (55.75 KiB) Viewed 2370 times
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

Re: Creating a Block

Postby spatialguru » Wed Jun 18, 2008 11:05 am

Attaching a zipped up version of the plugin - in case anyone wants to test it. Can you give guidance on header changes and attribution that I should use for sharing this?
sponsors_block.tar.gz
Sponsors Block Plugin Code
(2.4 KiB) Downloaded 179 times

Tyler
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

Re: Creating a Block

Postby spatialguru » Wed Jun 18, 2008 12:13 pm

Maybe this is too much of a play-by-play update for the forum, but I need to keep my notes somewhere anyway.

The above upload crashes the site when you move outside of a scheduled conference part of the site. So I added in some basic checks to make sure the block only renders when the page is for a scheduled conference and when there are sponsors recorded.

Full plugin updated here:
sponsors_block.tar.gz
Sponsors Block Plugin - with checks
(2.28 KiB) Downloaded 176 times


Parts updated below....

SponsorBlockPlugin.inc.php:
Code: Select all
...
        function getContents(&$templateMgr) {
                $schedConf = Request::getSchedConf();
                if ($schedConf){
                        $sponsors = $schedConf->getSetting('sponsors');
                        if ($sponsors){
                                $templateMgr->assign_by_ref('sponsors', $sponsors);
                                return parent::getContents($templateMgr);
                        }
                }
         }
...
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

Re: Creating a Block

Postby mcrider » Wed Jun 18, 2008 12:56 pm

Hi Tyler,

I've taken a look at your plugin.. Good work! I think it is a great addition for OCS. A couple of surface comments: You'll probably want to change the keys in the locale.xml files from plugins.block.developedBy.xxx to plugins.block.sponsors.xxx so that the title and descriptions shows up in OCS (and of course change the values themselves). And, if you can't translate the locale files, I think the best thing to do is delete the folders containing the languages you can't translate (it will show up as the locale key in other languages, and hopefully someone else will translate them).

Also, you probably want to put a <br /> after {translate key="about.sponsors"} in the template file, and/or before every sponsor name. With just a sponsor link in there (i.e., no image), it will put the block header and all the links on the same line and will probably confuse most users.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Creating a Block

Postby spatialguru » Wed Jun 18, 2008 2:01 pm

Thanks for the feedback - those changes made total sense.

Another thing I was wondering about were dependencies. In this case, unless you apply my sponsors settings patch, you can't specify logos at all in the site settings. Should this requirement be noted somewhere, e.g. in the plugin description? Or should I ultimately try to make my other patch into a plugin as well?
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

Re: Creating a Block

Postby tshore » Fri Mar 19, 2010 9:46 am

I display my sponsors - with logos - on the front page:

http://www.devpsych.ca/2010/

I just enter a filename for the logo in the Mailing Address box for each sponsor and then hardcode the path for the images into the template. Not my best work, but it keeps it simple. The reason I'm replying here, is that on the previous page, Matt says:
Everywhere else in OCS any request for the sponsors setting uses getSetting(), i.e. not localized. Could you try the same code again with getSetting('sponsors') instead of getLocalizedSetting('sponsors')...

I was wanting to be able to have different sponsor logos/urls for each language on this site, but when I tried to use getLocalizedSetting('sponsors'), it didn't work. Is this a bug?
tshore
 
Posts: 266
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Previous

Return to OCS Development

Who is online

Users browsing this forum: No registered users and 1 guest