Proper syntax for ListGetAt - list

I am getting a custom script error when trying to execute the following code. I might not have the proper syntax. I have googled ListGetAt examples and not able to find anything relevant. Thank you so much.
if(NOT isDefined(listGetAt(url.d,2,"/"))){
writeOutput("You're not allow to access the directory.");
}

You need to check the length of the list. I don't really understand what you are trying to achieve here but here would be the equivalent code with a length check...
if(NOT listLen(url.d,"/") gte 2){
writeOutput("You're not allow to access the directory.");
}

<cfscript>
url.d = "1/2";
if(NOT isDefined(listGetAt(url.d,2,"/"))){
writeOutput("You're not allow to access the directory.");
}
</cfscript>
Hi Chung Lee,
I think your url.d value have not second element in that list values. I've tried to reproduce that index error. I got the same index error. I've added an example code for your testing purpose. Please try it.
Thanks.!

Related

How to add a new language in Sitecore 8?

I'm working on Sitecore 8 and want to add a new language but Im having a message:
The spell checker dictionary does not exist.
Could you please help me?
All the dictionary files are stored in sitecore\shell\Controls\Rich Text Editor\Dictionaries\ directory.
There is no en-AU dictionary there by default (there are en-UK and en-US dictionaries). You can use one of them I guess. Or you can try google en-AU and use something from the Internet "en-AU.tdf" google search.
I had the same issue. I was able to resolve it by editing the "InvalidItemNameChars" setting temporarily.
Our project had a patch for InvalidItemNameChars like this:
This setting is usually in web.config. If you don't find it there, check "/sitecore/admin/showconfig.aspx" for InvalidItemNameChars.
I had to remove the '-' from the value and create the language. You will not get the error on not selecting the spell checker. You can leave it empty.
Once you are done creating the language add the '-' back to the config (in my case it was a patch config).

cfapplication variable & error

I have just started ColdFusion development and am getting stuck at creating a cfapplication that stores a variable, to use at a later date. All the tutor has provided us with is the following:
"Create your own 'Application.cfm' and save it in the root folder
alongside your 'hello world' examples."
i have this so far
<CFAPPLICATION
name=“mySite”
sessionmanagement=“yes”
clientmanagement=“yes”
setclientcookies=“yes”>
I want to add in a variable message that says "hello world". But I have no idea how to do it. I have been searching the net, but can't find any help. I am also getting the following message but have found no help on to resolve it:
"The value of the SESSIONMANAGEMENT attribute is invalid. The value
cannot be converted to a boolean because it is not a simple
value.Simple values are booleans, numbers, strings, and date-time
values."
If someone could help me with these that would be great, or if you can perhaps point me in the direction of some good ColdFusion tutorials that would be even better. As sadly there doesn't seam to be many decent ColdFusion tutorial's around that explain what's going on. Thanks for any help, it's much appreciated.
The syntax to set your variable is:
<cfset application.message = "Hello World">
Your error might be caused by the curly quotes in your code.

Regex in cfif to check there's a parameter in URL?

I'm trying to display a block of code only if the parameter ?staff is appended to URL, e.g.:
display Link only if the current URL was loaded with www.blank.com/folder/?staff
Any thoughts?
I don't believe there is any kind of performance difference, but to me it's best practices to use StructKeyExists(url,'staff') rather than isDefined("url.staff"). Either one will definitely get the job done though.
You don't need to parse the url with a regex, It should be in the url variable already if defined
<cfif IsDefined("URL.staff")>

CFEclipse doesn't recognize structName in cfimage tag

This code:
<cfimage action="info" structName="imageInfo" source="#imagePath#">
is giving this error:
The attribute 'structName' is required for the tag. (Found:
[source, structname, action])
When I run this code in CFBuilder - everything is OK, but I must use CFEclipse.
What should I do (I use CF9)?
Thank you for your answers!
Of course this problem won't prevent you from running your application on ColdFusion. It is just an IDE warning that something is wrong.
You have a few options.
Try using a lowercase N in structName. i.e. structname. ColdFusion is not case-sensitive, but Java is, and CFEclipse is a Java application.
If that does not work, then it probably means that the dictionary file that drives the code assist is not correct. You can go earch forthose XML files and update them to include that attribute.
You can use CFBuilder. I know you said you can't, but I have to question why. You know there is a free version that is just as good as CFEclipse, right?
The problem is that there's a casing glitch in that file Peter mentions. There's one reference to "structName" to define the attribute itself, and another "structname" which is in the list defining which attributes are needed for action="info". If you make them both the same, then restart Eclipse, you should be OK (that's I've needed to do to make the error indicator go away).

How to get file attributes in ColdFusion 7?

I cannot find a function that tells me the attributes of a given file. I specifically need to get the file's size. How do I find this info.?
edit:
I think I found an answer, just not the answer I was hoping for:
So far till ColdFusion 7, there was no
good way to find information like
size, last modified date etc about a
file. Only way you could do that was
to use cfdirectory tag to list the
directory, get the query from it, loop
over the query until you hit the
desired file and then fetch the
required metadata.
http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8-part-ii.html
Anyone know of a better way?
I believe cfdirectory is your simplest answer - but note, you can use the filter attribute as your filename, and you won't have to loop over the result.
<cffunction name="getFileSize">
<cfargument name="filepath">
<cfreturn createObject("java","java.io.File").init(Arguments.filepath).length()>
</cffunction>
The CFLib FileSysLibrary has a bunch of file functions.
FileSize
FileSizeCOM
May be of particular interest