0

Hi I have a CF application that uses a form page to enter data into the input fields, then passes those fields as SESSION variables to the action page so that the use can view hwo the page is going to look. basically is an application to build new html documents/pages.

Everything so far works fine. I have need to keep adding input fields at various stages, and so I have added a text area for the purpose of adding a list of sorts which is a list of cross references to a particular product related to the page being built.

The cross reference list variable: SESSION.crossRefList is then passed to the action page and displayed in an unordered list by means of <cfloop> like so:

<cfif SESSION.crossRefList NEQ "">
<ul>
          <cfloop index="crossRefList" list="#FORM.crossRefList#" delimiters="#chr(13)##chr(10)#">
            <li><cfoutput>#crossRefList#</cfoutput></li>
          </cfloop>
        </ul>
</cfif>

All is fine with this except: Each page may have one list or it may have 20 lists. And each list is started with a brand name that is ideally enclosed in an <h3> tag.

I would love to be able for the data entry girl to enter this without having to actually enclose the first list item in <h3> tags, however, it ezcapes me on how this would be accomplished, since again this is completely dynamic and the number if list items is unknown. Here is an example of the lists I'm talking about, then you can see what I trying to figure out.

[B]Alpine[/B]
SKY10

[B]Apollo[/B]
Products Imager 100

[B]Best Hood[/B]
K15

[B]Callisto[/B]
3094071

[B]Cole-Parmer[/B]
Compound Microscope
Trinocular, Catalog No. A-48924-30

[B]Fenix[/B]
3069061

[B]Helix[/B]
3003051

[B]Kitchenaid[/B]

[B]Locos[/B]
3072071

[B]Lumos[/B]
3071071
3093071

[B]Rumex[/B]
3001061

[B]Solaris[/B]
3043061

[B]Sunnex[/B]
Flexible Halogen Light

[B]Thermadore[/B]
Hood Light HG5W36TS

As you can see, the lists are formatted like the above example. so when the data entry girl wants to build a page with a similar list, she would now do it like this:

<h3>Cross Reference</h3>
cross
lists

Having to manually enter any text formatting such as the <h3> tag or extra line breaks if needed.

I hope this all makes sense. Again, The way I have it now, the data entry girl has to type in the <h3> tags for the bolded texts above to be styled correctly. I would love to be able to have this done for her so she wouldnt have to worry about that. Thanks for any help and if you need any more info, let me know.

Edited by teedoff: n/a

4
Contributors
16
Replies
17
Views
6 Years
Discussion Span
Last Post by kha_tsn
0

ok well no replies but thought I would still update the progress I've had. Got some good help at adobe forums...lol

Still not working exactly the way I want, but its so close! here is the code I am using now to loop through the lists from my form field.

<cfif SESSION.crossRefList NEQ "">
          <h3>Cross References</h3>
          <br />
          <cfoutput>
            <cfloop index="brandGroup" list="#FORM.crossRefList#" delimiters="#chr(13)##chr(10)#">
              <ul>
                <h3>#listFirst(brandGroup,"#chr(13)##chr(10)#")#</h3>
                <cfloop index="productGroup" list="#listLast(productGroup,";")#" delimiters=";">
                  <li>#productGroup#</li>
                </cfloop>
              </ul>
            </cfloop>
          </cfoutput>
        </cfif>

This puts each text "item" in an actuall unordered list, but all text "items" are displayed only by the first loop so therefore gets the <h3> tag applied to every single item.

0

Got some good help at adobe forums...lol

... among others ;-)

Maybe it's lack of caffeine. But I've read the question twice and still don't understand what the data looks like. Could you give a sample of
A) the values you're using (FORM.crossRefList, SESSION.crossRefList, productGroup)
B) what the output SHOULD look like?

<cfloop index="productGroup" list="#listLast([/b]productGroup[/b],";")#" delimiters=";">

It's probably not a good idea to reuse the same name for your index variable.

0

Hi arrgh, ok let me post my code as it is now first, since I think this is how to loops should be and how the listFirst and listLast functions should be as well.

<cfif SESSION.crossRefList NEQ "">
          <h3>Cross References</h3>
          <br />
          <cfoutput>
            <cfloop index="brandGroup" list="#FORM.crossRefList#" delimiters="#chr(13)##chr(10)#">
              <cfloop index="productGroup" list="#listLast(brandGroup)#" delimiters="|">
                <ul>
                  <h3>#listFirst(brandGroup,"#chr(13)##chr(10)#")#</h3>
                  <li>#listLast(brandGroup, "|")#</li>
                </ul>
              </cfloop>
            </cfloop>
          </cfoutput>
        </cfif>

The user would type in words or multiple words seperated by the delimiters I have specified. Ideally the user might type in something like this:

Product Name
33244|33244-10|33244-15
Second Product Name
33990|33991|33992

Notice the text Product Name has a hard(carriage) return after it while the next three pieces of texts(numbers here) have the pipe delimiter after them.

The first text(Product Name) ideally would be placed in the <h3></h3> tags within the list at the top. The others would simply be unstyled in the list.

Here is an example of how Im trying to get them to display as.

Product Name
33244
33244-10
33244-15

Second Product Name
33990
33991
33992


You can view an example of the lists Im trying to work with here.
Go down to the bottom where the long lists start of cross references. The first one I think is "American DJ"

These lists are different for each page. There may be one lists or several lists. or even none at all. So the text area form field is dynamic which is why I was trying this way.

Hope that makes a little more sense. Let me know if you need more info or have any suggestions.

Edited by teedoff: n/a

0

Well maybe there would be another simplier solution...lol If she DOES enter all the text in the form field, if there were a way to highlight certain text and wrap them in heading tags, that would work as well!

Just a thought! lol

0

If every line has a hard carriage return at the end, that code won't work. The only way I can think of is to split the values on the carriage return, then check for a "|". If the line contains a "|" then it's NOT a header. Does that make sense?

<h3>Cross References</h3>
<cfoutput>
   <cfloop index="brandGroup" list="#FORM.crossRefList#" delimiters="#chr(13)##chr(10)#">
      <!--- header --->
      <cfif NOT find("|", brandGroup)>
           <h3>#brandGroup#</h3>
      <!--- detail line --->
      <cfelse>
           <ul>
           <cfloop index="productGroup" list="#brandGroup#" delimiters="|">
               <li>#productGroup#</li>
           </cfloop>
           </ul>
      </cfif>
   </cfloop>
</cfoutput>

Edited by arrgh: n/a

0

There's one potential problem though. If the "detail" line doesn't have at least 1 "|", there'd be no way to distinguish it from the produce name headers

ie
Product Name
33244
Second Product Name
33990

0

Yes that does make perfect sense, although I thought thats what I was doing at onme point or another, just not with a cfif statement looking for the delimiter. One question that I had thought of as I was typing my last post though. Say I have, as in previous examples a heading text with several list items beneath the heading text. What tells the loop to look for the next heading item?

I'm thinking that the carriage return is a poor choice for delimiters since in essence all the text would be run together anyway. Meaning if the typed:

Product Name //with a carriage return
numbers|other numbers| some numbers // so here if thats the end of the list,

whats telling the code how to begin a NEW list and the very next word would be the header text. DOes that make sense?

Gonna try your suggerstions out now. Thanks!

0

The code works! You're a genius! lol.....yes I think there will be some potential problems as you said with this logic. I guess what I would need would be a way to tell the code that here is the beginning of a heading tag word(or new list basically) and then all words after the specified delimiter would be plain text list items UNTIL if found the next heading tag word.


Atcually just tested it with two lists like so:


Cross Reference
cross|lists

Product Name
name|number

And the displayed results were:


Cross Reference
cross
lists
Product Name
name
number

Edited by teedoff: n/a

0

I guess what I would need would be a way to tell the code that here is the beginning of a heading tag word(or new list basically)

Yup. I suppose you could assume the 1st line is always a header, and every other line is a "detail" line. But like the previous method, it's only as solid as the data ;-)

0

Well it seemed to work as is. I think I might play around with the delimiters to find the best ones. She a very good typist, and the action page the form variables pass too is a preview page. Then this page has a final write to file button to complete the page build, so several ways to critique the display results BEFORE its too late. SHe can go back to the form page and correct anything she wants if needed.

One more question. Are you familiar with CKEditor? It was suggested to me in another forum as a content manager of sorts thats native to CF 8 and newer. I couldnt find it, so I'm thinking it may be native to the enterprise editions. Either way I really dont want to scrap the WHOLE page builder app I have worked on for over a month now anyway. But I was just curious about it for future reference.

Edited by teedoff: n/a

0

Not separately. I've only used a few cftextarea's which have the editor baked in. It'd probably be easier than trying to write the your own page builder. But your best bet is to try it out. See how well it fits in w/your app.

0

Well like I said, my app is pretty much done. And now that this part is coming together, its even better. I've worked on this for over a month now, so like I said, I would hate to trash it or completelty have to rework it. It works well for our needs, since the company site is very VERY basic style wise, as you may have seen from my link. Not my design, but my employer's lol

Anyway, thanks again! and I will do some more reading on the CKEditor.

0

Whether you trash the existing code or not is up to you. I suspect their point was that doing all this parsing and html coding manually is... well somewhat unusual ;-)

Edited by arrgh: n/a

0

Well the part I guess thats unusual is the fact that I'm using only one text area to enter potentially multiple lists defined by delimiters.

Using an array and a dynamic form control evidently is much better, as I have been told, but again somewhat over my head at this point and would take longer to work out. Since I needed to get this up and running quickly, I guess doing it this way was my initial option.

Again. it works fine! The text with one delimiter is displayed in a heading tag, then everything after that is displayed in a list tag with no styling. I even have it now where I can add multiple heading tag words by using the hard return.

After the return, a colon defines the heading text, then the pipe character for each list item.

If a heading doesnt have any list items, which is also very possible, then I used another cfif to look for any listLen(brandGroup) GT 1. That works too!

Edited by teedoff: n/a

0

I think you dont do this other way there are many error occure this script so solve this first.

0

Use <cfoutput name=qryName group="Colname'>

</cfoutput>

or Use
<cfloop list="#listname# index="x">

</cfoutput>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.