Setting up templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • borrisjd
    New Member
    • May 2009
    • 9

    Setting up templates

    I am working on a project where the client wants to have multiple templates that customers can choose from for their site. We want everything automated. We are going to host the site for the customer. Any ideas of how to set this up? I am familiar with java, jsp, java servlets, html, and a little php.
  • prabirchoudhury
    New Member
    • May 2009
    • 162

    #2
    hey..could you explain bit details abt how and what template you wnat to setup...

    Comment

    • borrisjd
      New Member
      • May 2009
      • 9

      #3
      The templates will be basically empty web site shells. The customer will choose one of the templates they like, and that will become their web site. The templates will be written in html for the most part, perhaps containing some jsp. We will be using a MySQL database to hold the options of the customer, i.e. which template, which color choices, what text do they want displayed in text field one for example.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Most of your work is going to have to be done in the Server Side code.

        You're going to have to write a template HTML page that will be rendered.

        Then you'll have to dynamically generate the styles for this page based on the user's selections. It'd probably be easiest to store the CSS code in your database ...but it's up to you how you implement it.

        You will also have to dynamically grab the text content for the web pages from your database as well.

        Comment

        • borrisjd
          New Member
          • May 2009
          • 9

          #5
          Would you just put the CSS code into say a text data type in the database? I was thinking using jsp calls to the database to redirect to a specific folder that would contain the web site, style sheet, jsp pages ... and have each template in its own folder. Is this more cumbersomethan just using the css?

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            I don't know much about JSP but from what I do know is that you pretty much write the HTML structure for the page....in specific places in the page you're going to have JSP code (that is executed on the server) which will write dynamic content into the page.

            So first you have to have some sort of HTML structure (template) that will generally lay out the page. Once you have this structure in place you can dynamically write the CSS and the content (text) into the page.

            So, for example, this would be your HTML structure and anywhere that I have comments you'll have to replace with JSP code that does what I've specified in the comments:
            Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
               "http://www.w3.org/TR/html4/strict.dtd">
            <html>
            <head>
              <title>
                <!-- Dynamically grab the title for the page -->
              </title>
             
             <style type="text/css">
                body{
                  //here you need to dynamically 
                  //grab the style for the body of the
                  //web site...
                 }
                .banner{
                  //here you need to dynamically
                  //grab the style used for the Banner
                  //displayed for the web page
                }
                .contentSection{
                  //here you need to dynamically
                  //grab the style used for the content (the text)
                  //displayed for the web page
                }
              </style>
            </head>
            <body>
              <div id="bannerSection" class="banner">
                <!---
                  Here you will dynamically display a Banner
                  It could be an Image, it could be some Text...
                  It could be whatever you want.
            
                  Note the "class" property in the <div> for this section.
                  This class will be linked up to the style which is used
                  to style this section...the style is dynamically
                  generated but because the class name is known 
                  it'll work.
                 -->
              </div>
              <div id="contentSection" class="content">
                <!---
                  Here you will dynamically display the content
                  (the text) for the web page..
            
                  Note the "class" property in the <div> for this section.
                  This class will be linked up to the style which is used
                  to style this section...the style is dynamically
                 generated but because the class name is known 
                 it'll work.
                 -->
              </div>
            </body>
            </html>
            The CSS can drastically change how the layout of the page is displayed but it doesn't actually change the HTML structure of the page.

            For example you could write CSS for the banner section that displays the banner above the page's content. Or you could write CSS that displays the banner section to the right or the left of the content.

            CSS is very powerful and can drastically change how websites look to the end user even though the HTML structure of the page is the same as another page.

            Comment

            • borrisjd
              New Member
              • May 2009
              • 9

              #7
              That makes sense. I have done all the dynamic work with the html code using jsp and php, does it work the same way in the style sheet?

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Wait a sec, are you creating external style sheets?

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  Originally posted by borrisjd
                  I have done all the dynamic work with the html code using jsp and php, does it work the same way in the style sheet?
                  it is possible to build CSS files through PHP (and I think JSP too), you only need to make sure the files are recognised as CSS by sending the appropriate headers.

                  Comment

                  • borrisjd
                    New Member
                    • May 2009
                    • 9

                    #10
                    I am fairly new to html and css. I thought the css were always external. I guess by your question they are not. So if I put the css inside of my html page I can use jsp to call to the database like I have done before. If I were to use external is it possible to make that dynamic as well?

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      Originally posted by borrisjd
                      I thought the css were always external.
                      not necessarily, but it makes maintenance much easier.

                      Originally posted by borrisjd
                      If I were to use external is it possible to make that dynamic as well?
                      yepp, there's not much difference.

                      Comment

                      • borrisjd
                        New Member
                        • May 2009
                        • 9

                        #12
                        Very cool. Thanks for helping. I think I have enough to get started. I'm sure I'll be back when I get stuck lol.

                        Comment

                        • Frinavale
                          Recognized Expert Expert
                          • Oct 2006
                          • 9749

                          #13
                          Actually it's probably cleaner to keep them as external style sheets.

                          In this case all you have to do is write a JSP page that returns a Style Sheet instead of HTML.

                          This JSP page (I'm going to call it "JspPageThatDyn amicallySpitsOu tStyleSheets") would look something like:
                          Code:
                              body{
                                //here you need to dynamically 
                                //grab the style for the body of the
                                //web site...
                               }
                              .banner{
                                //here you need to dynamically
                                //grab the style used for the Banner
                                //displayed for the web page
                              }
                              .contentSection{
                                //here you need to dynamically
                                //grab the style used for the content (the text)
                                //displayed for the web page
                             }
                          The JSP page that will display the website (the HTML) will request the external style sheet from the JspPageThatDyna micallySpitsOut StyleSheets like so:

                          Code:
                          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
                             "http://www.w3.org/TR/html4/strict.dtd">
                          <html>
                          <head>
                            <title>
                              <!-- Dynamically grab the title for the page -->
                            </title>
                          <link type="text/css" rel="stylesheet" href="/JspPageThatDynamicallySpitsOutStyleSheets.jsp?styleID=xyz"></link>
                          </head>
                          <body>
                          <!-- .....-->
                          </body>
                          Note the link.
                          It's making a request to the JspPageThatDyna micallySpitsOut StyleSheets, passing it a style ID as a parameter. The JspPageThatDyna micallySpitsOut StyleSheets will use the style ID to dynamically create the style sheet requested.

                          Comment

                          • Frinavale
                            Recognized Expert Expert
                            • Oct 2006
                            • 9749

                            #14
                            Originally posted by Dormilich
                            not necessarily, but it makes maintenance much easier
                            ...
                            yepp, there's not much difference.
                            Originally posted by borrisjd
                            Very cool. Thanks for helping. I think I have enough to get started. I'm sure I'll be back when I get stuck lol.
                            Hehe Dormilich you're too fast :)
                            (or maybe I'm just too slow)

                            Comment

                            • Dormilich
                              Recognized Expert Expert
                              • Aug 2008
                              • 8694

                              #15
                              It's always a good idea to send the appropriate headers along with the document
                              Code:
                              // PHP
                              <?php
                              header("content-type: text/css");
                              ?>
                              
                              // style sheet content here
                              there should be some adequate code in JSP

                              Comment

                              Working...