Putting cf variables in non cf files...

I had asked a similar question before, but this one is a bit different (and that one wasn't really answered completely anyway).  What I am trying to do is to read in a file that has cf variables in it (like '#VarName#'), and output it in the http response stream.
Basically, I am trying to create a themeable interface for my site.  So, in my CSS files, for things like colors and backgrounds, I want to place something where I can swap out that placeholder for a value.  This modified CSS content would be the only thing written to the stream, and altering the "content-type" header, it would be handled like a css file by the browser.
I though that if I used #'s to delimit variables, read the file, set the variables, and then use CFOUTPUT, I could do this.  Well, I guess I was wrong.  No errors were being thrown, and I was just getting the '#VarName#' directly in the output.
Then, I though about using a CFINCLUDE, and I used it in inline code, within a CFOUTPUT, and also a CFSAVECONTENT, but I was still just getting '#VarName#' in the output.
If possible, I want to stay away from having to do a global string replacement, but if that is the only way...
Does anyone have a way in which to do the task at hand?  I'll keep playing with it, and if I find something, I will let you all know...

Basically, I am trying to create a themeable interface for my site.  So, in my CSS files, for things like colors and backgrounds, I want to place something where I can swap out that placeholder for a value.  This modified CSS content would be the only thing written to the stream, and altering the "content-type" header, it would be handled like a css file by the browser.
I though that if I used #'s to delimit variables, read the file, set the variables, and then use CFOUTPUT, I could do this.  Well, I guess I was wrong.  No errors were being thrown, and I was just getting the '#VarName#' directly in the output.
The web server, by default, does not pass requests for CSS files to CF, so CF will never find out about said request, so none of the CFML in the CSS file will get processed by CF.  You can tell the webserver to pass requests for CSS files to CF, but then CF will need to process all requests for CSS files.  Not ideal.
You could rename your dynamic CSS files to have .CFM extensions, but then your browser won't consider them cachable, so you will lose a lot of the benefit of using CSS files: that the browser caches them, therefore lowering the overhead of making a request.  I am fairly certain using a combination of headers and HTTP codes one could get get the browser to cache the file, though.  But then you have the reverse problem: you lose the dynamicism of the CF-driven CSS file.
To be honest... I'd just have a bunch of themed CSS files and be done with it.  I don't imagine you will have so many combinations of themes that this becomes impractical?  Then CF handles the variable which identifies which CSS file to call in, given the current theme.
Adam

Similar Messages

  • [solved]variable using ~ from a file

    To put the things in short, I am trying to share some files/directory using quickserve and want to pass the file list thro' another file. before actual sharing I am trying to  test the actual file's existence but it fails with ~ / $HOME options.
    File : ToExport.txt
    contents:
    ~/Documents/File1.dot
    ~/Documents/File2.ods
    /mnt/backup
    the said file is passed as an argument to the bash script
    Test function ...
    for isvalid in $(cat "$1")
    do
    if [ -e "$isvalid" ]
    then
    echo "$isvalid passed for sharing"
    else
    echo "$isvalid does not exisits"
    exit 4
    fi
    done
    This fails. If I replace ~ with actual path it works.
    (It may be easy to replace the entire list with the actual path by the simple search & replace funtion but the indention is to use the short form  ~ or $HOME instead of typing full path.
    your inputs/correction are welcome
    Last edited by kgas (2010-09-28 17:11:41)

    This should work:
    #!/bin/bash
    #: Description : Checks file list to see files contained exist/are empty
    fileList=/home/tom/fileList
    ## Go through each file in the fileList
    while read aFile
    do
    ## expand tildes (~)
    eval aFile=$aFile
    ## check file exists
    if [ -e $aFile ]
    then
    ## check file is non-empty
    if [ -s $aFile ]
    then
    printf "%s is a file.\n" $aFile
    else
    printf "%s is an empty file.\n" $aFile
    fi
    else ## file does not exist
    printf "%s does not exist.\n" $aFile
    fi
    done < <( cat $fileList )
    That code is a little more readable too. You where using the variable "isValid" for a file name.
    Last edited by BaconPie (2010-09-21 10:29:51)

  • How to define and populate value to a variable in a text file

    hi all,
    i have a text file on unix server, when i read it through open dataset, is it possible to populate dynamic value to a variable in the text file. and is it possible to define a variable at any place in the text file?
    after this the program will send the internal table for emailing.
    thanks.

    Hi, If this file on server is a email template you can put some tags / marks and you can change it after you read it with OPEN DATASET / READ...
    Sample:
    OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    CHECK sy-subrc EQ 0.
    DO.
      READ DATASET p_file INTO lv_string.
      IF sy-subrc EQ 0.
        EXIT.
      ENDIF.
      REPLACE ALL OCCURENCES OF '((SYSTEM_ID))' WITH sy-sysid.
      APPEND input_file_tab.
    ENDDO.
    CLOSE DATASET p_file.
    on file there's a line with:
    This email was generated on server ((SYSTEM_ID))
    It will be translated to (sy-sysid = DEV):
    This email was generated on server DEV
    This is a "variable" like that you can use.

  • Best setup for a non-Mac file server?

    I have a dual xeon server, with a SATA RAID5 I want to use as a file server in a cross-platform environment.
    *What I've tried and the issues...*
    At first I considered using Windows 2003 (Win2k3) but Services for Macintosh (SFM) is an older version of AFP and thus only supports 31 character filenames. With all our Macs supporting SMB/Samba/CIFS and Apple touting that "Macs and PCs can co-exist harmoniously on the same network" I figured I would give that a try.
    SMB doesn't work.
    Sure I can create a connection, but transferring files is a completely different story. I'm trying to backup application and system data, but companies such as Adobe and Apple have named some of their files with special characters that can't be transferred over SMB. I know NTFS doesn't support these characters, but I though a Linux box using SMB would work fine. It doesn't. It's the protocol which keeps me from transferring the data. I end up with the lovely error message of "You cannot copy some of these items to the destination because their names are too long or contain invalid characters for the destination..." (what's sad is, if you google for " because their names are too long or contain invalid characters for the destination" you only get 6 results.)
    So I thought I would give NFS a try. Apple says "Viewed from Mac OS X, [connecting via NFS] is just like connecting to an Apple or Windows server." No. It's not. NFS shares don't even show up in the Finder's Network listing. There are also a pile of other hurdles which are only tackled by savvy, command-line using users.
    So that leaves me with AFP. Win2k3 doesn't support filenames longer than 31 characters, and Win2k8 is dropping SFM altogether. Off to choose a *nix flavor, but that requires Netatalk. It hasn't been updated in years, it has many bad performance reviews... and most distros have removed it. I can download and install it. Oh, but that requires I get the kernel source files. Then I have to create an RPM an that's not working... now I'm several levels deep in trying to figure out how to get Netatalk working and I'm not even sure it will work.
    *What's the best setup for a non-Mac file server?*
    FreeNAS seems promising, but it's in alpha/beta and they have all sorts of warnings regarding potential data loss. Sure there's ExtremeZ-IP, but I really don't want to spend $675 do something Apple claims OS X can already do. I can put just about any non-Mac OS on this thing... what's the best way to set it up so it works?
    Thanks much.

    Rick may be right because although i didnt think of it before i tend to have notoriuosly long classnames for my php classes and i have used samba on occasion (when rsync is out of the question for one reason or another) and never had a problem. I use kubuntu (feisty at the moment )with an ext3 filesystem. if i have a chance this evening ill give it a try and see what happens.
    You could also possibly use FUSE to use an ssh filesystem for the shares... i don tknow how that would figure in your back up though.
    Also if worse comes to worse you could tar or dmg the the necessary files... just some thoughts.
    Ill be interested to know what you end up implementing....
    OH one last thought... Compile Darwin from source and use that as your server

  • Quick question, where to put global variables

    Very quick question:
    where is the best place to put global variables,
    (e.g. a flag that turns on debug mode)
    if they are needed by the entire application?
    I'm guessing they should be placed in their own class.
    But should I make them public static final constants,
    and just do Globals.MYCONSTANT
    OR should i do "implements Globals" in all my other classes?
    The first way seems simpler and more logical,
    but in the examples for JSDT, they use the second technique.
    Any thoughts?
    thanks! =)

    I would suggest either creating a properties file for your globals, or adding them to the system properties at startup. Placing items like debugging tags in your code means that you have to change the code, recompile, and rejar before your change is implemented. Using system properties means that you simply have to change your command-line options (i.e., from -Dmyapp.debug=true to -Dmyapp.debug=false).
    Shaun

  • Can i use a environment variable inside a *.sql file?

    Hello,
    I want to create a external table.
    So i am using the command
    create or replace directory abc as 'C:\folder'.... inside a sql file.
    Now i want the path "C:\folder" to be dynamic as i am using this path in many other places also inside the sql file.So i thought to create a environment variable and put this value there.I tried using as %PATH% but it gives error..... where %PATH%=C:\folder.
    Can i use a environment variable inside a *.sql file?
    But how to do that or is there any other way.
    Thanks
    Swapna
    Edited by: user11018268 on Feb 19, 2010 1:03 AM

    user11018268 wrote:
    Actually what i want is the path "C:\folder" is not fixed it can be anything which i may not know the user may decide it later. Not supported. A directory object refers to a specific physical location (directory/folder) on a file system. Not a path.
    You can work around it by (creating and) using a function (running under a super user schema with authid definer privs). The caller (e.g. schema scott ) calls it with a physical path. E.g. GetDirectoryObject( 'C:\folder\2010\feb\week4' ).
    This function determines if there is an existing directory object for the path. If not, it uses a wildcard search to determine if there are any directory objects for parents in the path (e.g. for C:\folder\2010\feb or C:\folder\2010 or C:\folder ).
    If it finds a directory object, it interrogates the data dictionary to determine if the caller, schema scott for example, has read/write access on that directory object. If it has, it creates a new directory object and grants the caller read/write access to it. The function then returns the name of the directory object to the caller.
    The caller thus do not deal directly with directory objects. The function returns the object name given a physical path as input. Also, only a single base directory needs to be created (e.g. for C:\folder ) and access granted to the schema on it. Any sub-directory in that base directory can now be dynamically accessed by the schema.

  • IWeb and non-iWeb files @ same site?

    I have modified my CNAME at my personal domain site to forward to MobileMe, and I am not having any problems with that aspect. What I am wondering is ... can I have both iWeb files and non-iWeb files at the same site and still use MobileMe?
    Basically, I want to use iWeb for my main family web site, but still have my Wordpress blog as well as some older web pages that I don't want to convert to iWeb. Right now, anything that starts with my domain name is pointed to MobileMe, which precludes access to the non-iWeb files.
    Not sure if this is clear or not, but if anyone has any pointers, I would be very grateful.

    Thanks for the advice about putting the other files on MobileMe - I didn't know you could host non-iWeb pages there.
    Unfortunately, I actually don't want to store them there. My Wordpress blog is hosted on my own server (it's not a wordpress.com blog), and my old files are large and I don't want to burn up all the space on MobileMe. I have a ton of space and other good hosting services as my provider (doteasy). I do, however, like the features of iWeb for my main family page, so I want to be able to publish to MobileMe, but still have the domain function as well, with some pages accessible only through the domain, not MobileMe.

  • Loading Variables from a php file

    Im trying to get the stats from a shoutcast radio stations
    into flash so i can manipulate them into a nicer looking site.
    Anyway, ive identified the line on which the stats are
    updated (its in a php file, line 48):
    <stong>Current
    Song:</strong></b><p><marquee>
    Morel&#x27;s Grooving Again - That Melody [Morel&#x27;s
    Groove Mix]</font></p>
    and i was wondering the following things:
    is it possible to have flash load only this line of text from
    the php file,
    how do i get flash to recognise "<stong>Curren Song" as
    the variable
    how to get flash to recognise the colon sign as meaning that
    that is waht the variable is equal to,
    and how, once flash recognises the parameter, to remove the
    formatting code from the text.
    Or is there an easier way of getting this variable into
    flash, like using some kind of self-updating html file...
    help would be much appreciated.
    thanks

    u can convert the array in to a string in FLEX and in PHP u can use the "split" command...
    here s sample program see if it helps u
    http://flexarraytransfer.blogspot.com/
    similary u can transfer VARIABLES also,in the place of the string just put ur variable on the PHP use t variable without spliting t

  • PATH VARIABLES AND RUNNING CLASS FILES

    People:
    I'm a complete Java neophyte and (slowly) learning. Rather than using the NetBeans IDE I have installed, I'm taking the text editor approach to type my source code.
    After I type code into my text editor, does it necessarily matter where I save my text files? For my first application, I created HelloWorldApp.java in Notepad, originally saving the file to the same folder where my J2SE 5.0 installation is stored, which is:
    C:\Program Files\Java
    My javac (Java compiler) is located in:
    C:\Program Files\Java\jdk1.5.0_01\bin
    When I was first trying to compile HelloWorldApp.java, I received errors saying the Java compiler couldn't be found; I was told to create a path environment variable so the javac could be found to compile my code. When I went to the control panel to set an appropriate path variable, I deleted a (wacky!) Roxio path (don't even know how that got there), entering in its place:
    C:\Program Files\Java
    as the new path name, although, again, my Java compiler is located in
    C:\Program Files\Java\jdk1.5.0_01\bin
    After restarting my computer to implement the new path variable into the operating system, I tried compiling my program, but still got error messages. However, when I moved my HelloWorldApp.java text file from the location where I originally saved it, which was:
    C:\Program Files\Java
    to
    C:\Program Files\Java\jdk1.5.0_01\bin
    my HelloWorldApp.java finally compiled to a class file, which I finally ran! Did my program run because I moved the HelloWorldApp text file from C:\Program Files\Java into the C:\Program Files\Java\jdk1.5.0_01\bin folder where the javac is located?
    Or did my C:\Program Files\Java path variable allow for the Java compiler to be found, although it's located in C:\Program Files\Java\jdk1.5.0_01\bin ? (This is why I asked above if it matters where you save your text document source code.)
    In using a text editor to type source code, where should I save my Java text files next time?
    Any help would be much appreciated! Thanks!

    Add the following directories to the PATH variable.
    C:\Program Files\Java\jdk1.5.0_01\bin
    I agree with this part.
    and add the following to the CLASSPATH variable
    C:\Program Files\Java\jdk1.5.0_01\lib;C:\Program
    Files\Java\jdk1.5.0_01\jre\lib;.
    Where is this insanity coming from?
    You do not need to set your classpath unless you are using a third party library or you have different parts of your program stored under different paths.
    OP: You can store your source files anywhere you want to. You should put them somewhere that is easy for you to access. Most people have a common directory for all of their projects, with subdirectories for each project.
    The only real restriction on where you put your source files is that the directory struction they are in must match the package statement at the top of the source file.
    So, if your file has:
    package chat.client.events;
    at the top, then the source file must be in a directory named chat/client/events relative to where you keep your source files.

  • Select non-consecutive files using keyboard

    Hi - I am trying to select several files in Finder using keyboard only. Sort of thing you would do with the CTRL key in Windows. I want to select several songs to open in my iTunes, but not all of them. And the songs are not listed one after another. I don't want to use the mousepad as it tends to open one of the selected file if I press the mousepad a tad too long. I just want to quickly scroll with arrow keys and mark the ones I want to select with another key. How can this not be possible on OS X?

    Thanks, it's just not helpful. Sometimes you happen to accidentally double-click, epsecially when you are selecting a large number of files. The problem here was that I was trying to select songs from my folder to open in iTunes so that I would transfer them to my iPhone afterwards in one go. The moment I would accidentally double-click wth the trackpad, the entire selection that I had made would open in iTunes and start playing, which meant that I would have to switch to iTunes and press pause. I did not want to put the computer on silence because I had some other music playing on YouTube at the same time. Overall, it's a disturbance. If someone at Apple were smarter, they would have allowed for a simle selection of non-consecutive files by keyboard, as Windows does it. Scrolling and selecting with the trackpad is not very convenient in this case, because you have to use the trackpad and the keyboard (CMD) at the same time. In a situation like this, a user should be able to perform this operation with keyboard only, simply because it is more convenient that way. If Windows with its operating system has been allowing to do this for ages, Apple with its ambition to be smarter and easier than PC should have been able to tackle this problem long time ago.

  • OMBPlus - TCL - reading variables out of text file

    Hello,
    i want to read out variables from a text file.
    For example to connect
    OMBCONNECT $login/$pass@$host:1522:$service
    and those 4 variables are in a text file.
    i'm a newbie, so it could be a stupid question
    thanks!

    I should point out that, if you are just using this for variable config then there is a far easier way to do this. Put the assignments in a separate .tcl file and then simply use the "source" command to read it. This becomes very handy as you start to build a library of functions that you will want to re-use across multiple scripts. Think of the command "source" to mean "copy that file and paste it into this one right here"
    For example, I have a config file and a library file.
    The config file might look like:
    #file config.tcl
    # GLOBAL VARIABLE DECLARATION SECTION
    #CORPORATE DESIGN REPOSITORY  CONNECTION INFORMATION
    # Login info for the design repository owner
    set OWB_DEG_USER    michael
    set OWB_DEG_PASS    mypassword
    set OWB_DEG_HOST    ourhost.company.net
    set OWB_DEG_PORT    1611
    set OWB_DEG_SRVC    orcl And a library file of functions called omb_library.tcl
    Now, in all my scripts it starts with:
    # File Some_Script.tcl
    #  Get Current Script name (excluding file extension), Directory and time
    set dtstmp     [ clock format [clock seconds] -format {%Y%m%d_%H%M}]
    set scrpt      [ file split [file root [info script]]]
    set scriptDir  [ file dirname [info script]]
    set scriptName [ lindex $scrpt [expr [llength $scrpt]-1]]
    #  Library and config file are in same directory as the script
    set cnfg_lib "$scriptDir/config.tcl"
    set owb_lib  "$scriptDir/omb_library.tcl"
    #  Import Library and config file
    #get config file
    source $cnfg_lib
    #get standard library
    source $owb_lib
    #  Create a subdirectory under the runnign directory, and create a log-file
    #   in that directory based on the script name and timestamp
    set LOG_PATH "$scriptDir/logs"
    file mkdir $LOG_PATH
    set    SPOOLFILE  ""
    append SPOOLFILE $LOG_PATH "/log_"  $scriptName "_" $dtstmp ".txt"With this block I eliminate the need to hardcode directories. As long as my config and library files are located with the script I can deploy them anywhere and they will get read and used.
    Cheers,
    Mike
    Edited by: zeppo on Mar 10, 2010 7:40 AM

  • Variable subsitution for target file names

    Hi All,
    I am using variable subsitution for dynamic file names. I am using the multimapping for multiple files in the target.So i coluld not able to use the dynamic configuration for file names. Now i want to replace all the spaces in the filename to underscore.
    For example
    My payload filed value "file name in the target file".
    Now my filename  "file_name_in_the_target_file".
    How to achieve this using Variable subsitution.
    Regards,
    Ramalakshmi.G

    Use replaceString Function.
    file name
    Constant (" ")               --> replaceString -------> TargetField
    Constant ("_")
    Regards
    Ramesh

  • Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi- Dist Build LLB Image.vi- Dist Build App Image.vi- Build Application.vi

    When trying to build  an application using labview 7.1 and windows XP,  I get the error
    Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi->Dist Build LLB Image.vi->Dist Build App Image.vi->Build Application.vi
    I've tried the crtl-shift-run as well as  a mass compile and I still get the error.
    Any ideas?
    Thanks,
    Mike

    Hopefully this thread, or this KB article might help.
    It seems like this could come from a lot of things, but there's suggestions in those which might lead you in the right direction
    Message Edited by Day on 09-22-2006 02:07 PM

  • How to put multiple classes in a single file?

    Hello,
    I'd like to put mutliple classes in a single file. (This
    would be useful for grouping children that are minor extensions of
    parent classes or helper classes that are used by one class only).
    When I tried to put two classes in one file, I got this error
    message:
    5006: An ActionScript file can not have more than one
    externally visible definition: Notation.editField,
    Notation.labelField1
    This is the structure I used. Thanks in advance for your
    help.

    You can declare multiple classes in a single file, but only
    one can be
    within the package declaration. All class declarations
    outside the package
    are invisible to code outside the file.
    package sample
    public class SampleClass
    class SampleClassHelper
    class SampleClassHelper2

  • Acrobat 9.3.4 no longer finds bookmarked non-PDF files (and then launches assoc app)

    I produce a documentation DVD consisting of a one-page PDF file of ~ 1400 bookmarks and a lot of content.  The bookmarks point to the content on the DVD which includes pdf files as well as text, DOC, XLS, and other misc. file types, and a large number of html, swf, flv, .jpg, etc. files which make up 4 complete web sites.  The web sites are entirely contained on the DVD (no extermal internet access is referenced or required)
    Content is accessed by clicking a bookmark which simply opens the file (regardless of type.)  Prior to Acrobat 9.3.4, appropriate warnings popped up for non-PDF files but if allowed by the user, the appropriate app was launched for the requested file.
    Since applying 9.3.4, a "Launch File" warning box pops up showing the file name (which lacks a device) and when the warning's "Open" button is pressed, a Windows error appears with the message "Windows cannot find 'file.txt'.  Make sure you typed the name correctly, and then try again.  To search for a file....  ", and finally an Adobe Acrobat information box pops up and says "Could not open the file 'path/file.txt'  ".
    I have read and re-read about launching external apps, restricted urls and attachments, trust manager preferences, etc. etc.  I've added the files to the privileged locations list under the enhanced security settings and on and on.  It no longer works, yet I tested this DVD on several computers just last week and it worked fine. So, as a shot in the dark, I decided to fire up my laptop and test it there again.
    Once on, the laptop immediately wanted to update about 12,000 software products but I politely said "No, wait until i test this out!"  The test was successful and the DVD's pdf file worked great again!  At that point I let the machine apply the Acrobat 9.3.4 update (and some uncountable number of Windows patches and fixes.)  It's running a current version of Win7.  After the reboot, i tried the DVD again (under Acrobat 9.3.4) and it failed as described above.  Because of Win7 I was able to revert to acrobat 9.3.2 using System Restore.  After doing that, the DVD worked again.
    Most of our user's machines are either Macs or WinXP (current versions) and i haven't had time to figure out if you can even recover from this update under those OS's.  (It says you cannot remove it from XP, however.)  Regardless, even if i can do it for my laptop and get it working again, i cannot do it for all of our users.
    So, my question is if i am not doing something wrong, how do i let someone at Adobe know this release is broken??  If i am doing something wrong on the other hand, what is it and how do i get this to work again??
    Thanks all.

    Thanks.  I did submit a report at the site.  I hope somebody reads it as this is a big problem for us.
    Thanks again.

Maybe you are looking for