Difference between revisions of "Style (CSS) and Eloquence (Languages)"

From EPrints Documentation
Jump to: navigation, search
(Creating the theme)
(Creating the theme)
Line 106: Line 106:
  
 
</pre>
 
</pre>
 +
 +
=== Adding Some Images ===
 +
 +
There are a number of reasons your might add images to a theme. Maybe you want a colourful background image or maybe you want to make EPrints icons fit in with the rest of your theme. In this example my goal the later although the mechanism works for the former.
 +
 +
I want to replace RSS feed icons. To do this I create the directory themes/abstract_flash/style/images/. In this directory I can add image files which I then reference in my style sheet. The RSS feed icon already exists in EPrints and is used in the default style sheet. To replace it I simply create a file of the same name (in this case feed-icon-14x14.png). I'm using this icon I found on Icon Finder http://www.iconfinder.com/icondetails/42454/16/
 +
 +
wget http://cdn1.iconfinder.com/data/icons/iconic/raster/16/rss.png -O feed-icon-14x14.png

Revision as of 16:02, 5 December 2010

EPrints has a rather complex hierachy of style sheets. You have eprints default styles which is then overwritten (where appropriate) by a local theme which is then overwritten in turn by your repositories local style sheets. Themes have been around since EPrints 3.0 but they are almost never used because very few people ever style more than one repository. Themes are a pack of style sheets, images, templates, static pages, and javascript which can completely change the look and feel of an EPrints repository. In EPrints 3.3 themes have been revisited and polished up so that they can be easily made into EPrints Bazaar packages.

In this tutorial we will focus on how to make your own theme which can be packaged for the EPrints Bazaar.

Creating the theme

You will need to start by creating your own theme directory. In this tutorial my theme name will be "abstract_flash" so the directory I will create for my theme is <eprints_root>/archives/<archive_name>/cfg/themes/abstract_flash/

Adding a style sheet

The first and easiest thing to do is create a new style sheet for our theme. In EPrints 3.2 the default template has been changed to make the things you can do with CSS styles much more powerful.

Create a stylesheet in your theme's directory: <eprints_root>/archives/<archive_name>/cfg/themes/abstract_flash/static/style/auto/y_abstract_flash.css

Try out some simple style rules to change the appearance of your EPrints template. If you aren't comfortable with CSS or you're just feeling lazy you can copy my code from the box below.

.ep_tm_archivetitle {
        display: block;
        padding: 10px;
        color: #D4FAE7;
}

.ep_tm_menu, .ep_tm_header {
        background: none repeat scroll 0 0 #525252;
}

.ep_tm_logo {
        display: none;
}

.ep_tm_menu li {
        padding: 20px;
        display: inline-block;
        border-top: 2px solid white;
}

.ep_tm_searchbar {
        background: none repeat scroll 0 0 #D4FAE7;
        border-top: 1px solid #525252;
        border-bottom: 1px solid #525252;
}

.ep_tm_key_tools li a {
        color:#525252;
}

body {
        margin: 0;
}


Changing the template

Our theme can also contain a template. The template is the frame in which pages are displayed.

I suggest copying your template file from the lib directory lib/templates/default.xml. The template can go in either cfg/themes/abstract_flash/templates/default.xml or cfg/themes/abstract_flash/lang/[langid]/templates/default.xml (if you want a language specific template)

In this example I have moved the key tools bar so that it is a menu on the right of the screen. To do this you must edit your template and move the "login_status" pin from inside the search bar to below it. This exert shows what I have done:

 <table class="ep_tm_searchbar">
    <tr>
      <td> <!-- login_status pin was here--> </td>
      <td align="right" style="white-space: nowrap">
                <epc:pin ref="languages" />
        <form method="get" accept-charset="utf-8" action="{$config{http_cgiurl}}/search" style="display:inline">
          <input class="ep_tm_searchbarbox" size="20" type="text" name="q"/>
          <input class="ep_tm_searchbarbutton" value="Search" type="submit" name="_action_search"/>
          <input type="hidden" name="_action_search" value="Search"/>
          <input type="hidden" name="_order" value="bytitle"/>
          <input type="hidden" name="basic_srchtype" value="ALL"/>
          <input type="hidden" name="_satisfyall" value="ALL"/>
        </form>
      </td>
    </tr>
  </table>
</div>


<epc:pin ref="login_status"/>

You must reload your configuration for this change to take affect.

You should now find that login information is outside of the search search bar area. Now we apply some style rules to position it on the right and make it look slightly more attractive. The style rules i chose are below.


.ep_tm_key_tools {
        width: 200px;
        float: right;
        background: none repeat scroll 0 0 #D4FAE7;
        margin:0;
        border-left: 1px solid #525252;
        border-bottom: 1px solid #525252;
}

.ep_tm_key_tools li, .ep_tm_key_tools li:first-child {
        border:none;
        font-size: 110%;
        display: block;
        padding: 10px;
}

Adding Some Images

There are a number of reasons your might add images to a theme. Maybe you want a colourful background image or maybe you want to make EPrints icons fit in with the rest of your theme. In this example my goal the later although the mechanism works for the former.

I want to replace RSS feed icons. To do this I create the directory themes/abstract_flash/style/images/. In this directory I can add image files which I then reference in my style sheet. The RSS feed icon already exists in EPrints and is used in the default style sheet. To replace it I simply create a file of the same name (in this case feed-icon-14x14.png). I'm using this icon I found on Icon Finder http://www.iconfinder.com/icondetails/42454/16/

wget http://cdn1.iconfinder.com/data/icons/iconic/raster/16/rss.png -O feed-icon-14x14.png