How would I modify a template for serverside language?

Chris's Avatar

Chris

22 Oct, 2014 04:14 PM

I am working on building a new website in Cascade, I am very new. The current website (not in Cascade) has a few ColdFusion based pages (server side language, like PHP).

I would like to be able to make an XML block to allow for simple variable entry (a number). On load, I will need to feed this variable to Cold Fusion, based on that variable, certain content will load.

So do I just need to modify my current template, change the output, and make a little block for text entry? If so, how might I go about that?

  1. 1 Posted by Chris on 22 Oct, 2014 05:56 PM

    Chris's Avatar

    I am thinking I do not need another template, but rather a new Configuration Set. I copied the current one and change the output to ".cfm" (ColdFusion).

    So now I need a block to allow users to enter the variable. How would I get my ColdFusion in there though?!?!?

  2. 2 Posted by Chris on 22 Oct, 2014 06:12 PM

    Chris's Avatar

    [can someone please move this post to the appropriate category?]

  3. 3 Posted by Ryan Griffith on 22 Oct, 2014 06:50 PM

    Ryan Griffith's Avatar

    Hi Chris,

    It sounds like you are on the right track here. As you mentioned, you would need to add an Output to your Configuration Set so the page is published as a .cfm file on your web server. Then, you need to decide a) how you want to allow your users to input the data, and b) how you want to generate the Cold Fusion code.

    In the simplest use case, you can simply allow your users to edit the Cold Fusion code (and the data) within an XML Block and you would include that Block within a region in your Template. The code itself would be surrounded by #passthrough code sections so Cascade does not attempt to validate and render the content when viewing the page. If the code needs to be added to the very top of the published page, you would use #passthrough-top.

    If you would like to go with a more structured approach, you would create a Data Definition with the desired fields for your users to fill out and then use a Format in conjunction with a calling page index block (or the Velocity Locator Tool) to access that structured data and render the Cold Fusion code dynamically within your Format. Again, the code would need to be surrounded by code sections.

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by Chris on 23 Oct, 2014 03:21 PM

    Chris's Avatar

    I think I have everything set correctly, but I am having trouble actually using my variable:

    #set ( $page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
    
    #set ( $id = $page.getChild("system-data-structure").getChild("formID") ) 
    
    <!--#protect-top
    
    <cfoutput>#ucase("hello world:
    
    #protect-top-->
    
    $_SerializerTool.serialize($id,true)
    
    <!--#protect-top
    
    ")#</cfoutput>
    
    #protect-top-->
    

    The above outputs: HELLO WORLD:$_SerializerTool.serialize($id,true)

    Which is not helpful! How do I wrap this variable in ColdFusion?

  5. 5 Posted by Ryan Griffith on 23 Oct, 2014 05:48 PM

    Ryan Griffith's Avatar

    Hi Chris,

    You are very close. What type of field is formID? If it is a text field you can simply do the following:

    <!--#protect-top
    <cfoutput>#ucase("hello world: ${id.value}")#</cfoutput>
    #protect-top-->
    

    If it is a WYSIWYG field, you would use:

    <!--#protect-top
    <cfoutput>#ucase("hello world: ${_SerializerTool.serialize($id, true)}")#</cfoutput>
    #protect-top-->
    

    Please let me know if you have any questions.

    Thanks!

  6. 6 Posted by Chris on 23 Oct, 2014 06:54 PM

    Chris's Avatar

    "formID" is a text field.

    
    #set ( $page = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page") )
    #set ( $id = $page.getChild("system-data-structure").getChild("formID") ) 
    
    <!--#protect-top
    <cfoutput>#ucase("hello world: ${id.value}")#</cfoutput>
    #protect-top-->
    

    The above outputs: HELLO WORLD: ${ID.VALUE}

    I must be doing something really wrong. :)

  7. 7 Posted by Ryan Griffith on 23 Oct, 2014 07:47 PM

    Ryan Griffith's Avatar

    Hm, sounds like the there is either an issue with the way $id is being set or you may not be including a calling page index block in the page region. Either of these issues would cause the literal text of ${id.value} to be outputted by the Format as opposed to the actual text field value.

    When you have a moment, confirm if you have an index block added to the region and that you are referencing the field correctly (ie the field's identifier is indeed formID).

    Please let me know if you have any questions.

    Thanks!

  8. 8 Posted by Chris on 23 Oct, 2014 07:53 PM

    Chris's Avatar

    Belay that, I got it working!!! :D

    My poor ColdFusion skills goofed me up! I can't wait to switch all of this stuff out with PHP!

    Thank you so much for your help Mr. Griffith!

  9. Chris closed this discussion on 23 Oct, 2014 07:53 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac