Answered
Trying to get first sentence only - code not working
This is driving me nuts -the code works on one page but not
on another and I can't figure out why. The code I'm using to pull
out the first sentence from a field is as follows:
<cfset variables.firstsentence = Find( ".", #get_spotlight.description#)>
<cfoutput query="get_spotlight">
<p><#title#<br />
#Left(description, variables.firstsentence)# (<a href="database_spotlight.cfm?link_id=#link_id#">find out more...</a>)</p></cfoutput>
It's working here: http://www.richland.lib.sc.us/research.cfm
I'm trying to use the same code on another similar page,and the same code doesn't work. It only pulls the first 40 or so characters and I don't know why. I'm assuming it's something to do with the surrounding code, but I can't see what. Can anyone shed some light on this before I go totally nuts?
Here's the page I'm working on: http://www.richland.lib.sc.us/sample/linkstest6.cfm?subjecttype_id=16
And here's all the code (in case something else is causing the problem)
<cfquery name="get_links" datasource="links_1" dbtype="ODBC">
SELECT links.link_id, links.title, links.link, links.description, links.url_home, links.icon, links.url_tutorial, links.discus,
links.subscription, subjecttype.subject_name, subject.link_id, subjecttype.subjecttype_id, subject.subjecttype_id
FROM links, subjecttype, subject
WHERE links.link_id = subject.link_id
AND subjecttype.subjecttype_id = subject.subjecttype_id
AND (subject.subjecttype_id = #url.subjecttype_id#)
ORDER BY title
</cfquery>
<cfset variables.firstsentence = Find( ".", #get_links.description#,0)>
Output (with some extraneous HTML removed - sorry for the lengthy code - I'm sure there's probably a shorter, more elegant way to do this..:
<cfoutput query="get_links">
<cfif subscription IS "Yes">
<cfif icon IS "home">
<cfif url_home IS ""><!--- same url inhouse/remote --->
<p><img src="#icon#4.gif" alt="database icon" width="20" height="20" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><cfif get_links.discus IS "YES">
<img src="../images/discus_logo.gif" alt="DISCUS" width="61" height="17" align="absmiddle" /></cfif><br />
#Left(description, variables.firstsentence)#<br /><a href="#link#" title="#TRIM(title)# - inside the library">inside the library</a>|
<a href="#link#" title="#TRIM(title)# - home access">home access</a>
|<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif></p>
<cfelse><!--- show two urls inhouse/remote --->
<p><img src="#icon#4.gif" alt="database icon" width="20" height="20" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><cfif get_links.discus IS "YES">
<img src="../images/discus_logo.gif" alt="DISCUS" width="61" height="17" align="absmiddle" /></cfif><br />
#Left(description, variables.firstsentence)# <br /><a href="#link#" title="#TRIM(title)# - inside the library"> inside the library</a>|
<a href="#url_home#" title="#TRIM(title)# - home access">home access</a> |<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif>
</p>
</cfif>
<cfelseif icon is "inhouse"><!--- show inhouse url --->
<p><img src="#icon#4.gif" alt="database icon" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><br />
#Left(description, variables.firstsentence)# <br /><a href="#link#" title="#TRIM(title)# - inside the library">inside the library</a> | <a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif></p>
</cfif>
</cfif>
</cfoutput>
<p> </p>
<h3>Librarian - Selected Web Sites</h3>
<cfoutput query="get_links"> <!--- non-subscription sites--->
<cfif subscription IS "No">
<p><img src="#icon#4.gif" alt="database icon" align="absmiddle"/>
<a href="#link#" title="#TRIM(title)#">#TRIM(title)#</a><br />
#Left(description, variables.firstsentence)# <br />
<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a></p>
</cfif>
</cfoutput>
Thanks for reading this far, and for any assistance or suggestions.
<cfset variables.firstsentence = Find( ".", #get_spotlight.description#)>
<cfoutput query="get_spotlight">
<p><#title#<br />
#Left(description, variables.firstsentence)# (<a href="database_spotlight.cfm?link_id=#link_id#">find out more...</a>)</p></cfoutput>
It's working here: http://www.richland.lib.sc.us/research.cfm
I'm trying to use the same code on another similar page,and the same code doesn't work. It only pulls the first 40 or so characters and I don't know why. I'm assuming it's something to do with the surrounding code, but I can't see what. Can anyone shed some light on this before I go totally nuts?
Here's the page I'm working on: http://www.richland.lib.sc.us/sample/linkstest6.cfm?subjecttype_id=16
And here's all the code (in case something else is causing the problem)
<cfquery name="get_links" datasource="links_1" dbtype="ODBC">
SELECT links.link_id, links.title, links.link, links.description, links.url_home, links.icon, links.url_tutorial, links.discus,
links.subscription, subjecttype.subject_name, subject.link_id, subjecttype.subjecttype_id, subject.subjecttype_id
FROM links, subjecttype, subject
WHERE links.link_id = subject.link_id
AND subjecttype.subjecttype_id = subject.subjecttype_id
AND (subject.subjecttype_id = #url.subjecttype_id#)
ORDER BY title
</cfquery>
<cfset variables.firstsentence = Find( ".", #get_links.description#,0)>
Output (with some extraneous HTML removed - sorry for the lengthy code - I'm sure there's probably a shorter, more elegant way to do this..:
<cfoutput query="get_links">
<cfif subscription IS "Yes">
<cfif icon IS "home">
<cfif url_home IS ""><!--- same url inhouse/remote --->
<p><img src="#icon#4.gif" alt="database icon" width="20" height="20" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><cfif get_links.discus IS "YES">
<img src="../images/discus_logo.gif" alt="DISCUS" width="61" height="17" align="absmiddle" /></cfif><br />
#Left(description, variables.firstsentence)#<br /><a href="#link#" title="#TRIM(title)# - inside the library">inside the library</a>|
<a href="#link#" title="#TRIM(title)# - home access">home access</a>
|<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif></p>
<cfelse><!--- show two urls inhouse/remote --->
<p><img src="#icon#4.gif" alt="database icon" width="20" height="20" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><cfif get_links.discus IS "YES">
<img src="../images/discus_logo.gif" alt="DISCUS" width="61" height="17" align="absmiddle" /></cfif><br />
#Left(description, variables.firstsentence)# <br /><a href="#link#" title="#TRIM(title)# - inside the library"> inside the library</a>|
<a href="#url_home#" title="#TRIM(title)# - home access">home access</a> |<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif>
</p>
</cfif>
<cfelseif icon is "inhouse"><!--- show inhouse url --->
<p><img src="#icon#4.gif" alt="database icon" align="absmiddle"/>
<span class="bold">#TRIM(title)#</span><br />
#Left(description, variables.firstsentence)# <br /><a href="#link#" title="#TRIM(title)# - inside the library">inside the library</a> | <a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a>
<cfif url_tutorial IS NOT "">|
<a href="../../pdf/#url_tutorial#" ><img src="tutorial4.gif" alt="Tutorial" width="20" height="20" align="absmiddle" /></a>
</cfif></p>
</cfif>
</cfif>
</cfoutput>
<p> </p>
<h3>Librarian - Selected Web Sites</h3>
<cfoutput query="get_links"> <!--- non-subscription sites--->
<cfif subscription IS "No">
<p><img src="#icon#4.gif" alt="database icon" align="absmiddle"/>
<a href="#link#" title="#TRIM(title)#">#TRIM(title)#</a><br />
#Left(description, variables.firstsentence)# <br />
<a href="database_spotlight.cfm?link_id=#link_id#"><img src="moreinfo4.gif" alt="More Information" width="20" height="20" align="absmiddle" /></a></p>
</cfif>
</cfoutput>
Thanks for reading this far, and for any assistance or suggestions.