OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



How to remove and add something in sidebar and main page?

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

Moderators: jmacgreg, michael, John

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

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. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

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 OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

How to remove and add something in sidebar and main page?

Postby huangs3 » Wed Jun 06, 2007 9:44 pm

Hi! I wanted to remove the "font size" block and "browse" block at side bar. I logged in and clicked around
"Conference Site Management">"website management"

but couldn't find the options.

Then I tried to do it with .css file. I use "view source" from IE and get the generated html code for font size:
Code: Select all
<div id="sidebar">
                <div class="block">
                      ......
                </div>
                   ......
   <div class="block">
      <span class="blockTitle">Font Size</span>
                                         ......
   </div>
</div>


From the common.css file I found the corresponding code:
Code: Select all
#sidebar div.block {
   font-size: 1em;
   padding-bottom: 1.5em;
}

However, if I add the
Code: Select all
display: none
attribute, to this place of .css file, all the blocks in the sidebar can become invisible.

With .css file I cannot control the id of the "font size" block. So do I need to modify the .php files which generating the html code? Or I can do it in other way?

I also want to add some link in the main page, seems this is the same issue as removing some part.

Waiting for ideas and suggestions. Thank you![/quote]
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

re: How to remove and add something in sidebar and main page

Postby mj » Thu Jun 07, 2007 8:08 am

Hi,

Unfortunately, at the moment, the sidebar blocks do no have unique ids that allow them to be hidden individually using CSS. In order to accomplish this, you'll have to edit the file: /templates/common/sidebar.tpl and either remove or comment out the lines for the sidebars that you want to hide.

The next release of OJS will include a Layout Manager plugin which allows a journal manager to control the ordering and appearance of the sidebar - as well as hiding blocks and choosing an optional 3-column layout - without having to modify any code.

Hope this helps,

MJ Suhonos
OJS Development Team
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Postby huangs3 » Thu Jun 07, 2007 8:43 am

Hi mj,

Thank you for let me understand the structure of OCS more. Your message helps and I will check into the tpl files if necessary :)

Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby mj » Thu Jun 07, 2007 8:52 am

Hi Sui,

A quick note -- I mistakenly read the forum as OJS, not OCS. The approach of editing sidebar.tpl will still work for OCS, but the forthcoming plugin is, at present, only available for OJS. However, because the two applications use a common framework, it's not unlikely that we may port the Layout Manager functionality into a future OCS release.

Apologies for any confusion I may have caused.

MJ Suhonos
OJS Development Team
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Postby asmecher » Thu Jun 07, 2007 9:12 am

Hi all,

Just to add to MJ's response -- the next release of OJS, OCS, and the Harvester will contain custom div IDs so that you'll be able to customize each sidebar component's display via CSS, although the forthcoming layout manager plugin is the preferred method of doing this.

In the meantime, I'd recommend commenting out the relevant code using Smarty's comment tags, {* and *}, e.g.:
Code: Select all
{* This content between Smarty comment tags will not be parsed *}
That way the patch-based upgrade method will be less likely to run into a conflict during upgrades.

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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Postby huangs3 » Thu Jun 07, 2007 11:19 am

Thank you asmecher:
A small question, is the Smarty related to .tpl file mentioned by MJ?
Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby asmecher » Thu Jun 07, 2007 2:35 pm

Hi Sui,

The .tpl files are Smarty templates, written in the Smarty templating language, which is described at http://smarty.php.net. They are basically HTML files with some additional tags embedded using { and } symbols, which are executed on the server side.

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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Postby huangs3 » Sun Jun 10, 2007 2:01 pm

Thank you asmecher:
I got a further questions at .tpl files and Smarty.
I want to move the links of "overview", "call for paper", etc, at sidebar, such that they stay at a horrizontal bar just underneath the title header. I move this second of code from template/common/sidebar.tpl to template/common/header.tpl and make a bit modification
Code: Select all
   {if $currentSchedConf}
      <span class="blockSubtitle">{translate key="schedConf.contents"}</span>

      <ul class="plain">
         <li>» <a href="{url page="schedConf" op="overview"}">{translate key="schedConf.overview"}</a></li>
         {if $schedConfShowCFP}
            <li>» <a href="{url page="schedConf" op="cfp"}">{translate key="schedConf.cfp"}</a>{if $submissionOpenDate} ({$submissionOpenDate|date_format:$dateFormatLong} - {$submissionCloseDate|date_format:$dateFormatLong}){/if}</li>
         {/if}
         {if $schedConfShowSubmissionLink}
            <li>» <a href="{url page="presenter" op="submit" requiresPresenter="1"}">{translate key="schedConf.proposalSubmission"}</a></li>
         {/if}
         <li>» <a href="{url page="schedConf" op="trackPolicies"}">{translate key="schedConf.trackPolicies"}</a></li>
         {if $schedConfShowProgram}<li>» <a href="{url page="schedConf" op="program"}">{translate key="schedConf.program"}</a></li>{/if}
         <li>» <a href="{url page="schedConf" op="presentations"}">{translate key="schedConf.presentations.short"}</a></li>
         {if $schedConfPaymentsEnabled}<li>» <a href="{url page="schedConf" op="registration"}">{translate key="schedConf.registration"}</a></li>{/if}
         <li>» <a href="{url page="about" op="organizingTeam"}">{translate key="schedConf.supporters"}</a></li>
         {if $schedConfPostTimeline}<li>» <a href="{url page="schedConf" op="timeline"}">{translate key="schedConf.timeline"}</a></li>{/if}
      </ul>
      {/if}


Is this the best method?


Another question is about smarty. I found this statement in template/common/sidebar.tpl:
Code: Select all
<span class="blockSubtitle">{translate key="schedConf.contents"}</span>

by guessing I can understand this is a line to display something. However when I try to find the meaning of the keywords "translate" and "key" in smarty website, I just couldn't find it. What are the meanings?

Thank you!

Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby asmecher » Sun Jun 10, 2007 8:05 pm

Hi Sui,

The {translate key="..."} function is a custom addition to Smarty. It finds locale-specific pieces of text in the currently used locale file, e.g. locale/en_US/locale.xml for most pieces of text in English.

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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Postby huangs3 » Wed Jun 13, 2007 10:28 pm

Hi asmecher,
Thank you for your explaination. How to find the definition of the custom addition to Smarty {translate key="..."} ? Since I want to understand how each part is working.
Thank you!
Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby asmecher » Wed Jun 13, 2007 10:43 pm

Hi Sui,

This function is implemented in classes/template/TemplateManager.inc.php as the smartyTranslate function:
Code: Select all
/**
 * Smarty usage: {translate key="localization.key.name" [paramName="paramValue" ...]}
 *
 * Custom Smarty function for translating localization keys.
 * Substitution works by replacing tokens like "{$foo}" with the value of the parameter named "foo" (if supplied).
 * @params $params array associative array, must contain "key" parameter for string to translate plus zero or more named parameters for substitution.
 *      Translation variables can be specified also as an optional
 *      associative array named "params".
 * @params $smarty Smarty
 * @return string the localized string, including any parameter substitutions
 */
function smartyTranslate($params, &$smarty) {
        if (isset($params) && !empty($params)) {
                if (isset($params['key'])) {
                        $key = $params['key'];
                        unset($params['key']);
                        if (isset($params['params'])) {
                                $paramsArray = $params['params'];
                                unset($params['params']);
                                $params = array_merge($params, $paramsArray);
                        }
                        return Locale::translate($key, $params);
                 } else {
                        return Locale::translate('');
                }
        }
}
...and it's registered as a Smarty function using:
Code: Select all
$this->register_function('translate', array(&$this, 'smartyTranslate'));


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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Postby huangs3 » Thu Jun 14, 2007 6:58 pm

Hi asmecher,
Thank you! I understand more now.
Just another simple question. I notice that some .php files are named like filename.inc.php, but some are filename.class.php
obviously the later is to define some php class, but what is the "inc" in the former? know the naming convention may help me to know the system more easily.
Thank you!
Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby asmecher » Fri Jun 15, 2007 9:20 am

Hi Sui,

These are just different naming conventions. OCS includes the Smarty library, which calls its classes by the .class.php convention; OCS itself uses .inc.php. There is no real difference. The "inc" stands for "include", which indicates that the PHP file isn't meant to be called directly by the server, but should instead be included from another PHP script.

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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Postby huangs3 » Fri Jun 15, 2007 9:41 am

Thank you asmecher,
Understand.
Another question, is there any way to get a Use Hierarchy to see which php file is using which quickly? Because I want to customize it but got lost in the files.
Thank you!

Sui
huangs3
 
Posts: 15
Joined: Mon Jun 04, 2007 4:01 pm

Postby asmecher » Fri Jun 15, 2007 10:05 am

Hi Sui,

There's a section in the OJS Technical Reference called "Request Handling" (pages 10 - 12) that describes locating request handling code. If you want to find the template file being used, for example, just look at the end of the handler function for a line like:
Code: Select all
$templateMgr->display('user/index.tpl');
In some situations, e.g. where Form classes are used, you'll need to look for the Form constructor. In these cases, the handler function will look like:
Code: Select all
        function profile() {
                parent::validate();
                parent::setupTemplate(true);

                import('user.form.ProfileForm');

                $profileForm = &new ProfileForm();
                $profileForm->initData();
                $profileForm->display();
        }
In this case, the form class is in classes/user/form/ProfileForm.inc.php, and in its constructor you'll find:
Code: Select all
parent::Form('user/profile.tpl');
...which tells you what template file is being used.

There are consistent naming standards, so once you get the hang of this, it'll become more intuitive.

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: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Next

Return to OCS Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests