Skip to main content
Known Participant
March 31, 2008
Question

format cfinclude

  • March 31, 2008
  • 2 replies
  • 556 views
I have over a thousand files that are headers to other files. Some headers are really long and I want to limit the output to a maximum of 40 characters, instead of outputting the file name. I know this example doesn't work but this is how I would output the first 40 characters if if were in a database.
<cfinclude template="#left(filename, 40)#">



This topic has been closed for replies.

2 replies

Participating Frequently
March 31, 2008
If you would have interest on having full word on endings. I would suggest something like following example.

<cfsavecontent variable="myContent">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam cursus aliquam ipsum. Vestibulum at ante. In bibendum placerat augue. Nullam posuere. Praesent vitae nisl. Proin rhoncus diam consequat diam. Donec in dui. Sed hendrerit hendrerit eros. Vestibulum diam orci, bibendum non, fermentum sed, lobortis vitae, eros. Nunc tempor, urna sed gravida sodales, nulla leo consectetuer nunc, eget sagittis mi lacus id diam.</cfsavecontent>

<cfset maxChar = 150>
<cfset tempContent = Left(myContent,maxChar)>
<cfset myTruncatedContent = ListDeleteAt(tempContent,ListLen(tempContent,CHR(32)),CHR(32))>

Inspiring
March 31, 2008
> I have over a thousand files that are headers to other files.

surely there must be a better way to do what you are doing with those
thousands of files...


> Some headers are
> really long and I want to limit the output to a maximum of 40 characters,
> instead of outputting the file name.

very confusing... you want to limit the output of what? what filename
are you talking about?

if you want to limit the output of your cfincluded file, then you have
to do it within that file. you can;t do it from the calling page, short
of reading it in with cfhttp or alike, parsing its contents, shortening
it to 40 chars, writing it to disk as a file and then cfincluding that
file...



Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Rcain37Author
Known Participant
March 31, 2008
> I have over a thousand files that are headers to other files.

>>surely there must be a better way to do what you are doing with those
thousands of files...

Yes a database would be nice but these files are updated in a different department and then given to us and they are updated a few times a year. There are over 24,000 files and a certain number of those files are headers for different sections. I can distinguish which files are headers, by their file names, but I want to be able to output the content inside the file instead of the name of the file.

Here is the page I'm trying to improve. http://www.legis.state.wv.us/WVCODE/Code.cfm

Where it says 1-1 in the left hand column, I want that to say "ARTICLE 1. LIMITS AND JURISDICTION.", that is the text that is in the file. Each hyperlink in the left hand column is an individual page. I was wondering if anyone knew how to replace 1-1 with the text of the document. I could use a cfinclude to output "ARTICLE 1. LIMITS AND JURISDICTION." but it breaks up the spacing in the left hand column because it outputs the entire page.