Highlighted

Admin Section Needs to Show Styling

Explorer ,
Jan 25, 2016

Copy link to clipboard

Copied

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>

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;

    }

}

TOPICS
Getting started

Views

552

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Admin Section Needs to Show Styling

Explorer ,
Jan 25, 2016

Copy link to clipboard

Copied

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>

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;

    }

}

TOPICS
Getting started

Views

553

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 25, 2016 0
Adobe Community Professional ,
Feb 01, 2016

Copy link to clipboard

Copied

<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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 01, 2016 1
Explorer ,
Feb 02, 2016

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 02, 2016 0
Adobe Community Professional ,
Feb 02, 2016

Copy link to clipboard

Copied

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)>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 02, 2016 0
Explorer ,
Feb 02, 2016

Copy link to clipboard

Copied

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;

    }

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 02, 2016 0
Adobe Community Professional ,
Feb 02, 2016

Copy link to clipboard

Copied

You could improve the solution to:

public string function getBasePath(required string script_name){

        var path = getDirectoryFromPath(arguments.script_name);

        return path;

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 02, 2016 1
Explorer ,
Feb 03, 2016

Copy link to clipboard

Copied

By improve, do you mean make more redundant, so it doesn't break as easily?  I am thinking that their is value in keeping code simple and fast.  By fast I mean, keeping the code so it doesn't have to look for much with a function that could have variables available anyway.  I am asking, then, what you mean by improving?

And I am wondering, if this could address a similar question I have about my variables not being found without the get() function on each of them.  One site works without it, and another only works with it.  So I am going to get them both to work without the get() function, because they should be okay without it.  Or is that unrelated to the issue we are talking about?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 03, 2016 0
Adobe Community Professional ,
Feb 03, 2016

Copy link to clipboard

Copied

By improve I mean:

  • simpler (fewer lines of code)
  • less complex (one function call instead of two)
  • more efficient (your code adds / then deletes it)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 03, 2016 0
Explorer ,
Feb 03, 2016

Copy link to clipboard

Copied

Thank You

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 03, 2016 0