4 Replies Latest reply on Mar 31, 2008 9:16 AM by Newsgroup_User

    format cfinclude

    Rcain37
      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)#">



        • 1. Re: format cfinclude
          Level 7
          > 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/
          • 2. Re: format cfinclude
            Oğuz Demirkapı Level 1
            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))>

            • 3. Re: format cfinclude
              Rcain37 Level 1
              > 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.

              • 4. Re: format cfinclude
                Level 7
                without knowing how your files are formatted, your file naming
                conventions, your folder structure and where the left menu links come
                from and how they are formed, it is pretty much impossible to suggest
                anything tangible...

                the easiest way will probably be to have the article/section name in the
                filename, which you can easily parse...

                the harder way will be reading in a file and parsing the article/section
                name out of its contents...



                Azadi Saryev
                Sabai-dee.com
                http://www.sabai-dee.com/