Skip to main content
Jan 25, 2016 11:43 PM UTC
Answered

Admin Section Needs to Show Styling

I am creating an admin section now.  Should I go about this differently?  I have gone through the learncfinaweek tutorials and copied the back end admin from that site and pasted it in for the new site.  Is there more to connect than I am thinking to just paste in an admin section?  I am thinking if I changed the adminPath to point to CoreBelief(the new site), it should have enough code to at least display the styling.  It doesn't give an error, only no css displayed yet.

I can put the css and javascript up there if it will be helpful in finding the solution.  I was thinking it might be in the Application.cfc.

Here is how far it gets with the Application.cfc file narrowed:

Debugging Information

ColdFusion Server Developer11,0,07,296330
Template /CoreBelief/admin/login.cfm
Time Stamp 25-Jan-16 03:32 PM
Locale English (US)
User Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Remote IP 0:0:0:0:0:0:0:1
Host Name 0:0:0:0:0:0:0:1

Execution Time  

Total TimeAvg TimeCountTemplate
5 ms5 ms1top level C:\ColdFusion11\cfusion\wwwroot\CoreBelief\admin\login.cfm
1 ms1 ms1C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/customtags/layout.cfm
0 ms0 ms1CFC[ C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/errorBean.cfc | hasErrors() ] from C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/errorBean.cfc
0 ms0 ms1CFC[ C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/errorBean.cfc | init() ] from C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/errorBean.cfc
0 ms0 ms1CFC[ C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/system.cfc | getBasePath(/CoreBelief/admin/login.cfm) ] from C:/ColdFusion11/cfusion/wwwroot/CoreBelief/admin/cfc/system.cfc
6 ms STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
11 ms TOTAL EXECUTION TIME

red = over 250 ms average execution time

Application.cfc:

component {

        this.name='CoreBelief';

        this.datasource='CoreBelief';

        this.applicationTimeout=CreateTimeSpan(10,0,0,0);

        this.sessionManagement=true;

        this.sessionTimeout=CreateTimeSpan(0,0,30,0);

/*        this.ormEnabled=true;

        this.ormSettings= {

            logsql=true,

            dbcreate="update",

            cfclocation="com/entity"

            };

        this.invokeImplicitAccessor=true;

        this.sessioncookie.httponly = true;

        this.sessioncookie.timeout = "10";

        this.sessioncookie.disableupdate = true;

        function onApplicationStart() {

                application.myName='David Carlisle';

                application.myPosition='Freedom Fighter and Developer';

                return true;

        }

        function onRequestStart(string targetPage) {

                If(structKeyExists(url, 'reload')) {

                    onApplicationStart();

                    ormReload();

                }

        }

*/}

layout.cfm:

<cfparam name="attributes.section" default="" />

<cfparam name="url.message" default="" />

<cfif thisTag.executionMode eq "start">

<cfset adminPath = createObject('CoreBelief.admin.cfc.system').getBasePath(cgi.script_name)/>

<cfoutput>

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="utf-8">

    <title>#attributes.section#: My Personal Website</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta name="description" content="">

    <meta name="author" content="">

    <link href="#adminPath#/assets/css/bootstrap.min.css" rel="stylesheet">

    <link href="#adminPath#/assets/css/datepicker.css" rel="stylesheet">

    <style type="text/css">

      body {

        padding-top: 60px;

        padding-bottom: 40px;

      }

      .sidebar-nav {

        padding: 9px 0;

      }

    </style>

    <link href="#adminPath#/assets/css/bootstrap-responsive.min.css" rel="stylesheet">

    <!--[if lt IE 9]>

      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

    <![endif]-->

  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">

      <div class="navbar-inner">

        <div class="container-fluid">

          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

          </a>

          <a class="brand" href="#adminPath#/index.cfm">My Website Admin</a>

          <div class="nav-collapse collapse">

            <p class="navbar-text pull-right">

             <cfif structKeyExists(session,'emailaddress') && len(session.emailaddress)> Logged in as <a href="#adminPath#/logout.cfm" class="navbar-link">#session.emailAddress#</a></cfif>

            </p>

            <ul class="nav">

              <li <cfif attributes.section eq "home">class="active"</cfif>><a href="#adminPath#/index.cfm">Home</a></li>

              <li <cfif attributes.section eq "resume">class="active"</cfif>><a href="#adminPath#/content/resume/listworkexperience.cfm">Resume</a></li>

              <li <cfif attributes.section eq "blog">class="active"</cfif>><a href="#adminPath#/content/blog/listblogpost.cfm">Blog</a></li>

              <li <cfif attributes.section eq "portfolio">class="active"</cfif>><a href="#adminPath#/content/portfolio/listportfolio.cfm">Portfolio</a></li>

              <li <cfif attributes.section eq "system">class="active"</cfif>><a href="#adminPath#/content/system/listadministrator.cfm">System</a></li>

            </ul>

          </div><!--/.nav-collapse -->

        </div>

      </div>

    </div>

    <div class="container-fluid">

      <div class="row-fluid">

          <cfif len(trim(url.message))>

              <div class="alert alert-success">

                  #url.message#

              </div>

        </cfif>

</cfoutput>

<cfelse>

        </div><!--/row-->

    </div><!--/.fluid-container-->

    <cfoutput>

    <script src="#adminPath#/assets/js/jquery-1.7.min.js"></script>

    <script src="#adminPath#/assets/js/bootstrap.min.js"></script>

    <script src="#adminPath#/assets/js/bootstrap-datepicker.js"></script>

    <script src="#adminPath#/assets/js/custom.js"></script>

    <script type="text/javascript" src="#adminPath#/../../ckeditor/ckeditor.js"></script>

    <script type="text/javascript" src="#adminPath#/../../ckeditor/adapters/jquery.js"></script>

    </cfoutput>

  </body>

</html>

</cfif>

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
Feb 2, 2016 8:03 PM UTC

So I got into the system.cfc and changed that three to a two, below.  Since I have one less file path folder than the previous site, that makes sense.

Now, the <cfoutput>#adminPath#</cfoutput> gives /CoreBelief/admin

Thank You for your help.

component

{

    public string function getBasePath(required string script_name){

        var path = arguments.script_name & '/';

        for(var i =listlen(path,'/'); 3 < i; i--){

            path = ListDeleteAt(path,i,'/');

        }

        return path;

    }

}

8 replies

BKBK
Community Expert
Community Expert
Feb 1, 2016 7:36 PM UTC

<cfset adminPath = createObject('CoreBelief.admin.cfc.system').getBasePath(cgi.script_name)/>

Do you perhaps mean

<cfset adminPath = createObject('component', 'CoreBelief.admin.cfc.system').getBasePath(cgi.script_name)/>

The CSS and Javascript strongly depend on the value of this variable, so dump and examine it:

Verify: <cfoutput>#adminPath#</cfoutput>

Translate
Feb 2, 2016 7:01 PM UTC

Thank You for your response.

I changed the cfset to this:

<cfset adminPath = createObject('component','CoreBelief.admin.cfc.system').getBasePath(cgi.script_name)/>

and still no change.

When doing a <cfoutput>#adminPath#</cfoutput> in the above pages, it gives this: /CoreBelief/admin/login.cfm/

That slash at the end is throwing it, apparently.

Translate
BKBK
Community Expert
Community Expert
Feb 2, 2016 7:52 PM UTC

That test tells you all you needed to know. Your code is using adminPath as if it is a directory. Whereas it is actually the path to the file login.cfm.

To get the admin directory, try something like

<cfset filePath = createObject('component','CoreBelief.admin.cfc.system').getBasePath(cgi.script_name)>

<!--- Remove forward slash at the end --->

<cfset filePath = left(filePath,len(filePath)-1)>

<!--- Get directory path --->

<cfset adminPath = getDirectoryFromPath(filePath)>

Translate