Solved

Loop over a delimited List and create an <cfoutput> as shown in the .Img

Posted on 2012-03-29
10
219 Views
Last Modified: 2012-04-10
Hello experts,

I am need to Loop over a ; delimited List and create an <cfoutput> as shown in the .Img

Here is the List

Value ="Ketterer Stress Symptom Frequency Checklist; Symptom Checklist-90–Revised doi:10.1037/t01210-000 "

Please take a look at the img attached, need to create exact, also the numeric values in doi:10.1037/t01210-000 has to be a Hyper Link
DOI-test-and-measures.png
0
Comment
Question by:Dan_Schimo
  • 5
  • 5
10 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 37783969
<cfloop index="aVal" list="#value#" delimiter=";">
   #aVal#<br>
</cfloop>
0
 

Author Comment

by:Dan_Schimo
ID: 37784053
I am getting only the first record in the List

below is the Code I am using in the CFC, I am returning "thisLink" from the function.
also i need to put an href on the doi


<cfloop list="#arguments.record.Instrumentation#" index="thisTest" delimiters=";">
					
					<!---<cfset thisTestI = Trim(thisTest)>--->
					
					<cfsavecontent variable="thisLink">
					<cfoutput>
					<!---<span class="rdLinkItem"><a href="">#thisTestI#</a></span><br>--->
					#thisTest#<br>
					</cfoutput>
					<cfset result = result & trim(thisLink)>
				</cfsavecontent>
				
			</cfloop> 

Open in new window

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 37784079
you're using "thisLink" inside your cfsavecontent before you're done creating it...


      <cfset result = result & trim(thisLink)>
   </cfsavecontent>
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 39

Expert Comment

by:gdemaria
ID: 37784096
perhaps something like this... doesn't seem like you need the cfsavecontent just to create a variable that you then contact with another.  Just build the entire thing inside the cfsavecontent


   <cfoutput>
   <cfsavecontent variable="result">
    <cfloop list="#arguments.record.Instrumentation#" index="thisTest" delimiters=";">
       <span class="rdLinkItem"><a href="">#thisTestI#</a></span><br>
       #thisTest#<br>
     </cfloop>
   </cfsavecontent>
  </cfoutput>
0
 

Author Comment

by:Dan_Schimo
ID: 37784216
@gdemaria

Thanks for the catch , I put the cfset out side the cfsavecontent and now it is giving me the last record only,
0
 

Author Comment

by:Dan_Schimo
ID: 37784605
i modified the code something like this which works ,and gives an output

output
 but separating the doi and putting an href around the numerical in doi:10.1037/t01210-000 is getting tough

 
 <cfsavecontent variable="result">
        <cfoutput>
        <table >
            <cfloop list="#(arguments.record.instrumentation)#" index="i" delimiters=";">
                <tr>
                    <td>#i#</td>
					<td><cfset i = replaceNoCase(i, "doi*", "<span class=""correctedTerm"">hello</span>","all" ) >
					<cfif len(i)><a href=>#i#</a></cfif></td>		
					                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>
    </cfsavecontent>

Open in new window

0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 37785012
I'm not clear on what the output should be...  if no doi, then no link?

Maybe you can tweak this...

 <cfsavecontent variable="result">
        <cfoutput>
        <table >
            <cfloop list="#(arguments.record.instrumentation)#" index="aVal" delimiters=";">
                <tr>
                    <td>#aVal#</td>
					<td>
                    <cfif aVal contains "doi:">
                      <cfset theLink = listLast(aVal,":")>
                      <a href="#theLink#">#theLink#</a>
                    <cfelse>
                      &nbsp; <!--- no doi, so no link ---->
                    </cfif>
                   </td>					                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>
    </cfsavecontent>

Open in new window

0
 

Author Comment

by:Dan_Schimo
ID: 37785242
This works well , I am getting and out put looks like

op
However , I would like to remove the text marked inside the Yellow box ref fig.

I tried all the trim functions but they need a pos to start
0
 

Author Comment

by:Dan_Schimo
ID: 37785705
I have modified the code to suffice all the reqs, please let me know if there is any unforseen errors


<cfsavecontent variable="result">
        <cfoutput>
        <table >
             <cfloop list="#(arguments.record.instrumentation)#" index="aVal" delimiters=";">
                <tr>
				<cfif aVal contains "doi:">
					<cfset var PartDoi= aVal>
						<cfset  thisLink = listLast(aVal,":")>
						<cfset doi="doi:<a href=""#getLink(thisLink, baseURL)#"" target=""_blank"">#thisLink#</a>">
						<cfset PartDoi = Rereplace(PartDoi, Rereplace(doi,'<[^>]*>','','all'),'', 'all'  )>	
						<td>#PartDoi#</td>
							<td>#doi#</td>
					<cfelse>
					 <td>#aVal#</td>
					 <td>&nbsp;</td>
           	  	</cfif>		                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>     
    </cfsavecontent>
	

Open in new window

thanks gdemaria
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 500 total points
ID: 37786888
looks good!   The only thing is that you can't declare "var" anywhere except the top of your function, so this line should thrown an error..

<cfset var PartDoi= aVal>

just remove the var from this line and declare the variable at the top of your function to empty:

<cfset var PartDoi= "">
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question