[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Creating Basic Zope Applications

nobody@nowhere.com nobody@nowhere.com
Sat, 21 Sep 2002 13:51:30 -0400


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/SimpleExamples.stx#3-43

---------------

      You can create a more flexible way to define CSS information by
      factoring it out into a separate object that the header will
      insert. Create a DTML Document in the *ZopeZoo* folder named
      *style_sheet*. Change the contents of the document to include some
      style information::

        <style type="text/css">
        h1{
          font-size: 24pt;
          font-family: sans-serif;
        }
        p{
          color: #220000;
        }
        body{
          background: #FFFFDD;
        }
        </style>

        % Anonymous User - July 3, 2002 11:04 am:
         The use of repeated inline style sheets (which is what is happening here) is not good practice! Think about
         it: every time a page is created & sent to the user, that same chunk of CSS is being sent through the
         network. It's hardly going to lead to the destruction of the universe, of course - but it defeats part of the
         POINT of CSS. The great thing about CSS is that you can have it in a single file which only needs to be sent
         to a particular user ONCE. Their browser can then refer to exactly the same cache of style information for a
         selection of pages.
         It'd be a lot nicer here to tell us how to put in a consistent link to a CSS file - I mean, how to make sure
         it was "../../style/style.css" on some pages, and "style/style.css" on others, etc. [Dan]

        % Anonymous User - July 24, 2002 11:57 am:
         Ehh, this isn't the place to lecture people on the use of external style sheets; the purpose here is to show,
         in a vivid, easy-to-grasp way, how to pull together a finished page from a mixed set of components residing
         in different places in the acquisition path. A sentence reminding people that separate, LINKed stylesheets
         are generally more efficient would be enough.
         It might also be good, in this vein, to point out that different stylehseets (or other such components) can
         be placed in sections of thr "zoo" while still falling back on the same standard_html_header throughout.

        % Anonymous User - Aug. 10, 2002 11:38 am:
         Besides, there is a great product for handling CSS content: http://www.zope.org/Members/haqa/ZStyleSheet
         It might looks a bit confusing on the beginning, but it is very powerful and configurable.

         Avel'ien.

        % Anonymous User - Sep. 21, 2002 1:51 pm:
         In reference to the comment about using external stylesheets instead of inline ones. I have done this and it
         works for me. Add a property to the root folder called stylesheet and set its value to the name of the
         stylesheet stored within the root document. Then in your standard html header file add <LINK REL="stylesheet"
         HREF="<dtml-var stylesheet>" TYPE="text/css">. As long as this header is included at the top of your pages
         you will get the css file. And the good thing is if you want to change your css file just change that one
         property on the root folder. Also, if you want subfolders to have a different css then the root folder, just
         copy the stylesheet that is in the root folder and paste it inside the subfolder. Then the documents in the
         subfolder will use the stylesheet file located in the same subfolder.