Professional Web Applications Themes

Large scale website design - Part 2 - Macromedia ColdFusion

Here was my original question... Currently there is one main .cfm that has dozens of cfincludes > surrounded by cfifs that do logic based on a passed in page variable. e.g. > > someone clicks a link: > [url]www.foo.com/bar.cfm?page=takemehere[/url] > > in this case the bar.cfm is the main cfm page filled with statements that > look > similar to this: > > <CFIF page is eq takemehere> > <CFINCLUDE takemehere.cfm> > </CFIF> > > Intuitively this setup seemed rather clunky to me, as I have worked with > it > more and more I have gotten comfortable with it ...

  1. #1

    Default Large scale website design - Part 2

    Here was my original question...

    Currently there is one main .cfm that has dozens of cfincludes
    > surrounded by cfifs that do logic based on a passed in page variable. e.g.
    >
    > someone clicks a link:
    > [url]www.foo.com/bar.cfm?page=takemehere[/url]
    >
    > in this case the bar.cfm is the main cfm page filled with statements that
    > look
    > similar to this:
    >
    > <CFIF page is eq takemehere>
    > <CFINCLUDE takemehere.cfm>
    > </CFIF>
    >
    > Intuitively this setup seemed rather clunky to me, as I have worked with
    > it
    > more and more I have gotten comfortable with it and would like some
    > outside
    > feedback on how something like this should be properly done. Thanks in
    > advance.
    > -Jake

    Response...

    I agree with a couple of the other posters -- Use a database! Our main.cfm is
    one page long ... but services over 300 pages ...

    <cfinclude template = "#the_template#">

    Databases are your friend.

    My question now is how do you use a database to accomplish this? What does the
    table look like that stores the information (what fields does it have ect.) And
    how do you implement it?

    JakeFlynn Guest

  2. #2

    Default Re: Large scale website design - Part 2

    The easiest way to use a single page to load content based on a URL variable is
    like this:



    <cfinclude template="header.cfm">

    <table width="600" border="0" cellspacing="0" cellpadding="4">
    <tr>
    <td width="200" valign="top">
    <cfinclude template="navigation.cfm">
    </td>
    <td width="400" valign="top">
    <cfif FileExists(ExpandPath('content/' & url.page)>
    <cfinclude template="content/#url.page#.cfm">
    <cfelse>
    <cfinclude template="content/404.cfm">
    </cfif>
    </td>
    </tr>
    </table>

    <cfinclude template="footer.cfm">

    cf_menace Guest

  3. #3

    Default Re: Large scale website design - Part 2

    A more advanced way would be to pull page data from a database based on a url
    ID variable:

    TABLE: SITE_MAP
    ------------------------------
    SITE_MAP_ID | SITE_MAP_TEMPLATE | SITE_MAP_TITLE
    --------------------------------------------------------
    1 | content/welcome.cfm | Welcome to my site
    2 | content/forms/contact.cfm | Contact Us
    3 | content/catalog.cfm | Product Catalog

    You'd pass something like index.cfm?pageID=2, where index.cfm now looks like
    this:



    <cfquery name="getSitePage">
    SELECT SITE_MAP_TEMPLATE, SITE_MAP_TITLE
    FROM SITE_MAP
    WHERE SITE_MAP_ID = #url.pageID#
    </cfquery>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>#getSitePage.SITE_MAP_TITLE#</title>
    </head>

    <body>

    <cfinclude template="header.cfm">

    <table width="600" border="0" cellspacing="0" cellpadding="4">
    <tr>
    <td width="200" valign="top">
    <cfinclude template="navigation.cfm">
    </td>
    <td width="400" valign="top">
    <cfif FileExists(ExpandPath(getSitePage.SITE_MAP_TEMPLAT E)>
    <cfinclude template="#getSitePage.SITE_MAP_TEMPLATE#">
    <cfelse>
    <cfinclude template="content/404.cfm">
    </cfif>
    </td>
    </tr>
    </table>

    <cfinclude template="footer.cfm">

    </body>
    </html>

    cf_menace Guest

  4. #4

    Default Re: Large scale website design - Part 2

    Ok, good to hear I am currently refactoring my site to do just that. One
    problem that I am running into this is that some of the pages have special
    conditions for example:

    <CFIF page is "foo">
    <CFSET thisvar = that>
    <CFSET Session.thatvar = this>
    <CFINCLUDE template="foo.cfm">
    <CFIF page is "bar">
    <CFSET Session.adifferentvar = that>
    <CFSET anothervar = this>
    <CFINCLUDE template="bar.cfm">

    and so on and so forth. So if i do a single:

    <CFINCLUDE template="#page#.cfm">

    I am going to have to wrap it in about 20 if statments. That just seems ugly
    to me and almost negates the whole process. I know that it is hard to tell with
    out looking at the exact code (trust me you don't want to) but, is there
    another place that may be more appropriate to set these session vars and what
    not? Is there a design pattern workaround or am I just factoring a ty
    design that is going to take me alot longer than I thought?


    JakeFlynn Guest

  5. #5

    Default Re: Large scale website design - Part 2

    cf_menace,
    Thank you very much for your replies they are excellent! My question for you
    is where do you normally setup your session variables also. How would you
    handle the case where your first page is a log in page so you do not want to
    include the naviagtion bars with that page?

    JakeFlynn Guest

  6. #6

    Default Re: Large scale website design - Part 2

    Jake, depedning on how large your site is, you might want to look into FuseBox
    or Mach-II. Those are frameworks that provide more advanced functionality of
    the kind you're describing. I'm currently using a Struts-like XML configuration
    file to control page content, user access, security levels and a few other
    things.

    Without all that, right now you could just put a <cfif session.loggedin> check
    at the top of each of your content pages. If they're not logged in, kick them
    to the login form.

    HTH

    cf_menace Guest

  7. #7

    Default Re: Large scale website design - Part 2

    cf_menace,
    Thank you again. Do you have any good information on Struts and implementing
    it? This sounds like something that I would like to eventually implement. I
    know I am pushing my luck but I do appreciate your help.
    -Jake

    JakeFlynn Guest

  8. #8

    Default Re: Large scale website design - Part 2

    To elaborate I am looking for a good way to control user access and security levels. This Strut (Framework?) is something that I would like to research? have I made the right assumptions?
    JakeFlynn Guest

  9. #9

    Default Re: Large scale website design - Part 2

    I think i found what I am looking for with struts in case anyone was interested here is the link:

    [url]http://struts.apache.org/[/url]
    JakeFlynn Guest

Similar Threads

  1. Part of website not showing
    By Lexus22 in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: September 20th, 04:19 AM
  2. FlashComm Dployment on a Large scale hosting enviroment
    By blackpulp in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: August 19th, 09:43 PM
  3. Large Scale Website Design
    By Supra LTD in forum Macromedia ColdFusion
    Replies: 5
    Last Post: March 4th, 04:14 PM
  4. Maintaining large scale PHP applications
    By Colin McKinnon in forum PHP Development
    Replies: 3
    Last Post: September 5th, 07:09 AM
  5. Website too large!
    By Dr. Gary in forum Web Design
    Replies: 2
    Last Post: October 14th, 05:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139