Gregory's Blog

Using a dynamic variable to set a dynamic path variable when dropping a cookie

ColdFusion sometimes drives me a bit wonky when I try to set a dynamic variable inside a tag. Most ColdFusion tags support embedded dynamic variables, but quite a few tags don't support this. Probably the most frustrating issue is when you want to use a dynamic variable to extend an application in a sub-folder using two or more application.cfc templates. It seems that every other time I do this I slap my head and think 'Oops! it's time to set up proxy extensions', sigh... but this frustrating issue requires a very long blog entry for a different day. Back to my point...

If you try to use a dynamic variable using a cfcookie tag, you will get the following nasty error:

view plain about
1<cfcookie name="isAdmin" value="true" path="#application.baseUrl#" expires="never">

Attribute validation error for tag CFCOOKIE. It has an invalid attribute combination: expires,name,path,value. Possible combinations are: Required attributes: 'name'. Optional attributes: 'domain,encodevalue,expires,httponly,preservecase,secure,value'. Required attributes: 'domain,name,path'. Optional attributes: 'encodevalue,expires,httponly,preservecase,secure,value'.

To get around this, simply use the cookie scope instead in order to set the dynamic path value.

view plain about
1<!--- Using the cfcookie tag does not work with dynamic vars in the path. --->
2<cfset cookie.isAdmin = { value="true", path="#application.baseUrl#", expires=30 }>

Both cfcookie and the cookie scope do the same thing, send a cookie to the client, but at least the cookie scope allows you to embed dynamic variables for in the path name.

This entry was posted on June 28, 2019 at 12:11 PM and has received 200 views.

There are currently 0 comments. Download attachment.

Theme Settings in the administrative web interface.

Gregory's Blog has 14 different beautiful default themes that you can choose from. Each theme can be easily customized using a web interface. You can have as many themes as you want, or design a single theme, but you should first choose a default theme from which to start with.

All of the default themes can be viewed by clicking on the themes link at the top of each page. Once you choose a theme, you can adjust the settings of the theme, such as changing the header properties, page display settings, changing logo's, etc. After modifying the default theme to your liking, you can further fine tune the look and feel using a web based theme builder interface. I will cover how to use the theme builder in later posts.

Once you have selected your preferred theme, you can disable the other themes by deselecting the Use theme? checkbox under the Default Themes section in the administrative settings interface. Don't worry about losing a theme, you can always enable any theme by checking the checkbox next to the disabled theme.

There are 39 unique theme settings that can be independently applied to each theme. Theme settings are applied using the Settings page in the Blog administrative site. I will briefly go over each new setting here. It it safe to play around with these settings. If you make a mistake, you can always reset the default settings for the particular theme by clicking on the reset theme button at the bottom of the settings administrative page.

  • Notes: this blog is highly optimized for mobile, and some of these settings will not apply. I have indicated what settings are not available to mobile devices in the notes section below.
  • The following three settings are global, and affect all themes.
    1. Parent Site Name and Link: The parent site name and parent site link form elements controls the behavior of the menu found at the top of the header. It allows the user to add an option in the menu that links to their home site.
    2. The Parent Site Name will display the title of the site within the menu. On my site, the text is Gregory Alexander - Web Design. The Parent Site Link can be any link to another site. The link is triggered when a user clicks on the menu option. On this site, the link is www.gregoryalexander.com.
    3. Default Font Size will set the font size for the blog content. You can choose any value between 8 and 26 points. Note: the Default Font Size will not change the size of the text in the header. I manually set the header text to be at 16 point in the menu on desktop devices, and 12 points for mobile devices.

    All of the settings below can be set by theme. Each theme operates independently, and can have its own unique settings. You can modify or create 14 different themes.

    1. The Modify Default Themes checkbox is used when the owner of the blog is ready to modify the default themes. Until this button is checked, the site will operate as it is intended here, with the default settings intact.
    2. The Kendo Base Theme allows the blog owner to review all of the default blog settings. Blog owners can look and see where the current images are stored, what library paths are used, and determine the element properties of the containers on the site. It is recommended that you browse the existing themes, and choose the theme that is closest to the theme that you want to create. In order to modify a theme, click on the default theme that you are interested in, and modify the settings that are displayed in the form.
    3. Kendo Theme .css Location (string): if you want to create your own Kendo less based theme and replace the existing .less based theme, use the Kendo Theme Builder to modify the base theme, upload it, and change the default path and point it to the new .less file that you created using the Kendo theme builder.
    4. Kendo Mobile Theme .css location (string): when you create your own Kendo theme, make sure to also specify the new path of the mobile theme as well.
    5. Custom Theme Name (string): provide the theme name that you want others to see when they look at your own site. This setting has no effect on the 1.1 version, but is a placeholder for the next major release.
    6. Dark Theme (true/false): Gregory's blog has built in logic to pull in different resources depending upon the overall color of the theme. If the theme has a dark background for example, Gregory's blog will pull in a different version of the code highlighter. There are quite a few different adjustments that are made, but it is up to you to determine whether Gregory's Blog should adjust it's logic for to adapt to a light or a darker screen background. You can see this in action by comparing the following two default themes: Blue Wave (a light theme with dark text) and Blue Wave Dark, a dark theme with white text.
    7. Blog Content Width (numeric): The current blog content is set at 66% of the screen and should be left at this setting unless you set it much higher. When you're looking at the blog, you can see that the blog content portion in the center of the screen. The blog content section may contain the header (we will go over this later), the blog content that contains the blog posts, the side bar to the right which contains the links to the various parts of the site (such as the subscribe interface), and the footer. The blog owner can adjust this as they see fit, they can set it to 100% if they don't want any background image at all. However, unless you want to set this quite a bit higher, it is strongly recommended to leave this particular setting at 66%. If this setting is set at 66%, the background width is programmatically optimized and will change depending upon the screen width of the device. Note: this setting has no effect on mobile devices. To illustrate, the blog content width set at 100% is shown below (the 'Main Container' and 'Pod Container' widths were kept at default settings (65% and 35%)).
    8. Main Container Width (numeric): the main container holds all of the blog posts. It is currently set at 65% of the Blog Content Width (see above). If you set this higher, or lower, the side bar (also known as the 'pod width') to the right will also be adjusted accordingly. This setting has no effect on mobile devices. Note: the Main Container Width plus the Pod Container width will always equal 100. The following image has the following settings:
      1. Blog Content Width: 50%
      2. Main Container Width: 50%
      3. Pod Container Width: 50%
    9. Pod Container Width (numeric): the pod container is the section to the right of the main container. It contains the subscribe interface, tags, recent posts, etc. The current setting is set to 35%, but you can adjust it as you see fit. Notes: if you change this setting, the Main Container Width will be adjusted accordingly. This setting has no effect on mobile devices. The Main Container Width plus the Pod Container width will always equal 100.
    10. Opacity (numeric): If you look carefully at the site, you can see a faint trace of the background image underneath. I prefer this look as it creates visual interest. The opacity settings are different depending upon the theme, but you can change this setting to your own liking. You can set it at 100% to eliminate the opacity, or set it lower than the current setting if you want the background to bleed through. The image to the left has opacity set at 80%, and the right image is set at 99%.

    11. Background Image (string): enter the absolute path to the image that you want shown as the background image for the desired theme. If you prefer the look of a clean site without any background, or don't want any background at all, leave this blank. Additionally, you can specify an image that will create a background pattern, and use the next variable, Background Image Repeat .css, to create a unique pattern as a background. The image below does not have a background image set
    12. Background Image Repeat .css (string): you can use any valid background image repeat .css. This was built into the themes as a blog owner may want to create sophisticated pattern objects for the background. The pattern shown below image has the following settings:
      1. Background Image Repeat: repeat

    13. Background Image Position .Css (string): setting your favorite background 'hero' image using the default 'center center' is not always the best approach. The background image position rule allows you to set the background image to exact coordinates to make sure that it looks good on all screen sizes. See background position for more information.
    14. Stretch Header across Page (true/false): if you want your header to consume the entire width of the page, set this to true. The default setting is false. On mobile devices, this setting is automatically set at 100%. The image below is set to true.
    15. Align Header with Content (true/false): the default setting is true for all of the current default themes, but setting this to false allows the header to be set at the far left or right of the page, or the absolute center. Leaving this to true adjusts the size of the header to fit the width of the content width (see Blog Content Width).
      The image below has the Align Header with Content set at false with menu align center.
      Note: this setting is only relevant if the Stretch Header across Page is set to true.
    16. Menu Align (left, center, right): you can align the header to the left, center, or right. Use this in conjunction with the Align Header with Content and Stretch Header across Page properties to create the look that you like.
    17. Header Background Image (string): currently, I use simple images with various gradient fills that are used as the header background. You can set the header background to use any image. You can get creative here, perhaps you want an image that is filled with a pattern, or a header that displays lots of floating bubbles, it is your call.

    18. Cover Menu with Menu Background Image (true/false): this setting is a bit complex. For my personal Zion and Orion themes, I wanted a the color scheme on the menu to match the color scheme of the background images and the .less theme file that controls the forms and widgets. In order to have the selected menu item match the orange color scheme, I 'covered' the Kendo menu with the background image that I used on the header with .css. This setting allows the menu background image to be shown within the Kendo menu itself. All of the other current themes have this setting set at false. Setting this to false should be sufficient in most cases; the menu is already tailored to the .less based theme that is set. However, there are reasons that a blog owner may want to set this to true on occasion. For example, if a blog owner creates a menu image with a lot of little floating bubbles, setting this to true will also allow the menu items to show these little bubbles as well.
    19. Mobile Logo Image (string): You will want your mobile logo image to be much smaller than the logo image for desktop devices. Enter the absolute location of the image.
    20. Mobile Logo Image Width (numeric (pixel width): this typically is set to be 60 pixels or less.
    21. Desktop Logo Image (string): enter the absolute path pointing to the location of your logo that will be shown on desktop devices.
    22. Logo Padding (top, right, bottom, left)': you can fine tune the logo placement with these settings. The default settings are left at 0px.
    23. Blog Name Text Color (hexadecimal string): this setting controls the text color of all of the items in the menu. Use any valid hexadecimal or valid HTML color value. If using a hexadecimal value, make sure to put a pound in front of the hexadecimal string it as well.
    24. Header Divider Image (string). This is the horizontal image divider that separates the header and the blog content, and the blog content and the footer. Currently, it is a little grey bar, but you can design your own and specify it here using an absolute path.

    This entry was posted on June 24, 2019 at 4:40 PM and has received 186 views.

    There are currently 0 comments. Download attachment.

    ColdFusion error: "The current user is not authorized to invoke this method."

    I wanted to document this as this error is not often found using google, but if you receive a ColdFusion error "The current user is not authorized to invoke this method.", it could be due to using the roles attribute in a cfffunction tag that don't match the roles that you set using the cflogin tag upon successful login.

    I received this error when converting the original application.cfm tag in BlogCfc to use an application.cfc instead. During the conversion processes, I noticed that there was a 'roles' argument on the cffunction that did not match up with the new role that I had just programmed in the cflogin logic. When I searched for this error, I found a bunch of errors relating to using ColdFusions built in administrative user interface, and could not find that it was due to the role restrictions on the cffunction tag and thought to document it. It is a relatively intuitive error, but I am surprised that Adobe did not elaborate and write something like 'The role on the function does not match the cflogin role'. ColdFusion has always been good at that.

    If you receive this error, check the roles attributes that you have used. It will likely fix the problem.

    This entry was posted on June 2, 2019 at 2:32 PM and has received 278 views.

    There are currently 0 comments. Download attachment.

    Shorthand struct return

    There are many ways to return multiple values from a cfc. Typically we return a query object, a json string, an array, or a structure, but one of my favorite ways to return multiple bits of data is using a shorthand structure. It is much easier and intuitive to use on both the back and front end than using an array. Here is a simple example:

    Cfc:

    view plain about
    1<!--- There are two types of routing titles. The original design used an routing title that was used to populate a contract and this title was not the official title, but something more generic that was easily identifiable on a written contract. The other title is the official title that is coming from the workday database We will use the original routing title if the user was assigned a routing title that is found in the routing database, otherwise, we will use the official workday title. --->
    2 <cffunction name="getTitleByEmail" access="remote" returntype="struct" hint="Determines the approver title. This will be either the routing title that was used in previous contracts, or the official title found in workday. We need to return multiple values, so this returns a one dimension array instead of a string.">
    3 <cfargument name="email" type="string" required="yes" hint="Supply the email.">
    4
    5 <cfparam name="title" default="">
    6
    7 <!---Format the email--->
    8 <cfinvoke component="#WorkdayUsersObj#" method="formatUwEmail" returnvariable="uwEmail">
    9     <cfinvokeargument name="email" value="#arguments.email#">
    10        </cfinvoke>
    11
    12 <!--- Query the Approval database to see if the title exists. --->
    13 <cfquery name="approvalTitle" datasource="Contracts">
    14     SELECT TOP (1)
    15                ApproverTitle
    16                FROM dbo.Approval
    17                WHERE (Email = <cfqueryparam value="#uwEmail#" cfsqltype="cf_sql_varchar">)
    18 </cfquery>
    19 <!---Set the ApproverTitle--->
    20 <cfset ApproverTitle = approvalTitle.ApproverTitle>
    21         <!---Get the workday job title. --->
    22         <cfinvoke component="#WorkdayUsersObj#" method="getEmployeeJobTitle" returnvariable="workdayTitle">
    23            <cfinvokeargument name="email" value="#email#">
    24         </cfinvoke>
    25
    26 <!---Build the shorthand struct --->
    27 <cfset titleStruct = {workdayTitle = #workdayTitle#, ApproverTitle = #ApproverTitle#}>
    28
    29 <cfreturn titleStruct>
    30
    31 </cffunction>

    On the client side, simply use the following to output the value:

    view plain about
    1<cfset thisRoutingTitle = getTitleByEmail(thisApproverEmail).ApproverTitle>
    2<cfset thisWorkdayTitle = getTitleByEmail(thisApproverEmail).WorkdayTitle>

    This entry was posted on December 14, 2018 at 12:34 PM and has received 76 views.

    There are currently 0 comments.

    Localization Support Dropped

    I am going to forgo using Raymond's localization support for this version. To incorporate a few languages, Raymond uses the resourceBundle.cfc template that was originally coded by Paul Hastings. I believe that it supports two variants Dutch and German languages, along with English of course. Raymond labels his buttons and text messages in the different languages in 4 different .properties files, and uses the 'rb('message var') function to display the text and messages. I have decided not to incorporate the localization as I can't translate between English and the other languages, and this blog is also intended to be a living example how to use Kendo with ColdFusion. Using 'rb('pleaseWait') in my code will be confusing to the reader wanting to know how I am using ColdFusion and Kendo. It is much easier to read:

    view plain about
    1'$.when(kendo.ui.ExtWaitDialog.show({ title: "Please wait...", message: "Searching.", icon: "k-ext-information" }));'
    than
    view plain about
    1'$.when(kendo.ui.ExtWaitDialog.show({ title: "<cfoutput>#rb(pleaseWait)#</cfoutput>", message: "<cfoutput>#rb(searching)#</cfoutput>", icon: "k-ext-information" }));'
    for example. In one of the next versions, if someone wants to assist me in translating the English into the supported languages, I may revisit this decision and incorporate localization into the code.

    This entry was posted on December 8, 2018 at 11:15 PM and has received 94 views.

    There are currently 0 comments.




    Your input and contributions are welcomed!

    If you have an idea, BlogCfc based code, or a theme that you have built using this site that you want to share, please contribute by making a post here or share it by contacting us! This community can only thrive if we continue to work together.

    Images and Photography:

    Gregory Alexander either owns the copyright, or has the rights to use, all images and photographs on the site. If an image is not part of the "Gregory's Blog" open sourced distribution package, and instead is part of a personal blog post or a comment, please contact us and the author of the post or comment to obtain permission if you would like to use a personal image or photograph found on this site.

    Credits:

    Portions of Gregory's Blog are powered on the server side by BlogCfc, an open source blog developed by Raymond Camden. Revitalizing BlogCfc was a part of my orginal inspiration that prompted me to design this site. Some of the major open source contributers to BlogCfc include:

    1. Peter Farrell: the author of 'Lyla Captcha' that is used on this blog.
    2. Pete Freitag: the author of the 'ColdFish' code formatter that is also used on this blog.

    Version:

    Gregory's Blog Version 1.15 July 25th, 2019.