Skip to main content
Inspiring
May 26, 2012
Question

OnRequest automatically Load A background pattern on every page

  • May 26, 2012
  • 1 reply
  • 975 views

Good Morning,

I have an application.cfc page that works (see below). On every new page that i create the header and footer displays as expected. However i cannot figure out how to make it so that a image background will automatically display in my application.cfc. Is there a <cfinclude> background tag in which i can incorporate into my application.cfc page? Any suggestions.

<cfcomponent output="false">

<cfset this.datasource="bookstore">

<cffunction name="OnRequestStart" returntype="boolean" output="true">

        <!---Any variable set here can be used by all out pages--->

        <cfset request.company = "Books Wazu">

        <!---Display Header on every Page--->

        <cfinclude template="header.cfm">

        <cfreturn true>

    </cffunction>

   

        <cffunction name="OnRequestEnd" returntype="boolean" output="true">

        <!---Display Footer on every Page--->

        <cfinclude template="footer.cfm">

        <cfreturn true>

    </cffunction>

</cfcomponent>

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 26, 2012

    What you're doing is a bit of a misuse of onRequestStart / onRequestEnd.  They're more intended for request-establishment logic, not display considerations.

    Can I recommend you read up on MVC.

    As for a background image, this should be handled with your CSS, I think.  Not mark-up.

    --

    Adam

    BKBK
    Community Expert
    Community Expert
    May 27, 2012

    Adam Cameron. wrote:

    What you're doing is a bit of a misuse of onRequestStart / onRequestEnd.  They're more intended for request-establishment logic, not display considerations.


    I would disagree. In my opnion, the request-establishment logic may include display, particularly one related to style.

    As for a background image, this should be handled with your CSS, I think.  Not mark-up.

    I think so, too. Something like this might work:

    <cffunction name="OnRequestStart" returntype="boolean" output="true">

    <cfargument name = "targetPage" type="String" required="true">

    <link rel="stylesheet" href="/css/background_image.css" type="text/css">

    <cfreturn true>

    </cffunction>

    Here, I am assuming the style file background_image.css is in the directory css under the web root. Its content would, for example, be:

    body {

        background: url("http://127.0.0.1:8500/images/background.jpg") 50% 50% no-repeat;

    }