OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Different custom CSS file if user is logged in?

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.

Different custom CSS file if user is logged in?

Postby rmichael » Mon Jun 18, 2007 10:45 am

I would like to send a different CSS file depending on whether or not a user is logged in.

I see the template manager simply keeps and array of all of them in $styleSheets (and $stylesheets), which is iterated over in header.tpl.

What is the best place to build in a bit of logic? Is there a variable I can check (i.e. $userLoggedIn) in the Smarty template and do a hardcoded if/then include on a special CSS file in the TPL file, or should I modify the templateManager to add my special stylesheet if a user is logged in?

I want to do this because I've turned off a few items (display: none) in our journal customized CSS file, but want them on again when a user logs in.. In particular, I turned off the breadcrumbs, but need them for access to editorial/review/etc. pages when someone is logged in.

Thanks.
rmichael
 
Posts: 113
Joined: Fri Mar 30, 2007 3:32 pm

Postby asmecher » Mon Jun 18, 2007 11:11 am

Hi Richard,

The classes/core/TemplateManager.inc.php file would be a logical place to add this, particularly in the same bit of code where the isUserLoggedIn variable is assigned (around line 85). I'd suggest using the $this->addStyleSheet(...) function, which is used elsewhere in TemplateManager.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8419
Joined: Wed Aug 10, 2005 12:56 pm

Postby rmichael » Mon Jun 18, 2007 4:16 pm

Done. Perfect, thanks.

I looked at the assignment location, but decided to assign after the 'issset($journal)', where the custom journal style sheet is picked up. Though now that I think about it, perhaps it would be better to put it outside that block so that it would be picked up when there are no journals and an administrative user is logged into OJS itself, and not necessarily associated with a site. Actually, I can imagine two of these files, one for OJS and another per site. I don't need anything that advanced at the moment. :)

A CSS file applied when a user is logged in makes it quick to do things such as change colours to remind people they are logged in (and need to log out), or change layout, etc.

Although perhaps these changes should be done in the generated HTML (i.e. not even sending the elements to the browser in the first place). Only purely cosmetic changes should be in the stylesheet obviously.

Is it worth me cleaning this up as plugin, or will the coming layout tools provide this type of functionality? (I pick up the file from the journal's public files section -- cutting and pasting the code from the existing stylesheet detection, so I could add a journal setting to check and avoid hardcoding a path, uploading, etc. etc.).
rmichael
 
Posts: 113
Joined: Fri Mar 30, 2007 3:32 pm

Postby asmecher » Mon Jun 18, 2007 5:36 pm

Hi Richard,

This would be a great candidate for a plugin. I've just added theming support to CVS, which will be released with OJS 2.2, and you can even include these sorts of customizations as parts of a theme. I don't think we're likely to ship support for per-user CSS files, because it's a bit too specific for the average user -- however, if you do clean it up as a plugin, we'd be happy to post it as a contributed plugin.

Let me know if you have any questions about plugin development.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8419
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 10 guests