Hi Mike,

UDF can access any shared scope variables ie, session, application, request,
client etc - but usually better to loosely couple by passing in everything
you need as arguments to the function - makes it more reusable om om om om.
Sorry got carried away with the mantra for a moment.

<cffunction name="showGraphic">

 <cfargument name="LastLoginDate"  type="date" />
 <cfargument name="Created"    type="date" />
 <cfargument name="LastModified"  type="date" />

 <cfset var sImage = "" />

 <cfif LastLoginDate lt Created>
  <cfset sImage = "<img src='new.gif'>" />
 <cfelseif LastLoginDate lt LastModified>
  <cfset var sImage = "<img src='updated.gif'>" />
 </cfif>

 <cfreturn sImage />

</cffunction>

<cfloop query="qArticles">

 <cfoutput><p>#showGraphic(session.auth.LastLoginDate, Created,
LastModified)# #Title#</p></cfoutput>

</cfloop>


Can use a good old custom tag for this too.




"Michael Kear" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> I have a need to write a UDF (or another concise way to use functionality)
> to do the following:
>
> I have a session.auth.lastlogin field in the session vars to tell me when
> the user was last here,   and I have a field Dateadded and Dateupdated in
> every document, and I want to put a little "NEW" graphic or "UPDATED"
> graphic next to each article in a documents list if it's been added or
> changed since the user was last here.  Also at the head of the document
when
> the user looks through the site.  SO it's going to be used often.
>
> I want to be able to put in the code something like this:
>
> <cfif Isnew(docID)><img src="new.gif"></cfif> #documents.title#
>
> How would I write a UDF to tell CF whether to add a "new.gif" or
> "updated.gif" or have no graphic (if the document is unchanged since the
> user was last here)?
>
> I have been reading up on writing UDFs, but none seem to show me how to
> include both the session variable and the document ID in the functionality
> here.
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> AFP Webworks
> http://afpwebworks.com
>
>
>
>
>
>



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to