{"id":305,"date":"2011-06-24T14:21:16","date_gmt":"2011-06-24T19:21:16","guid":{"rendered":"http:\/\/www.cfchimp.com\/wordpress\/?p=305"},"modified":"2024-12-05T19:47:20","modified_gmt":"2024-12-06T00:47:20","slug":"add-a-last-modified-date-to-fw1-framework-one-pages","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2011\/06\/add-a-last-modified-date-to-fw1-framework-one-pages\/","title":{"rendered":"Add a last modified date to FW\/1 (Framework One) pages"},"content":{"rendered":"<p><strong>Disclaimer<\/strong>:<\/p>\n<ol>\n<li>I&#8217;m a total newb to FW\/1.<\/li>\n<li>There is most likely a better, or built in way to do this.<\/li>\n<\/ol>\n<p>Still with me?\u00a0 Ok.\u00a0 Here is the specification for this little ditty:<\/p>\n<ol>\n<li>The site I&#8217;m working on is mostly static.<\/li>\n<li>It is required (perhaps legally, definitely procedurally) that every page of the site must have a last modified date in the footer.<\/li>\n<li>The site is built using FW\/1 (which is awesome).<\/li>\n<\/ol>\n<p>Here are the cliff notes of what&#8217;s about to go down:<\/p>\n<ol>\n<li>I have a footer that is included in every page.<\/li>\n<li>In the footer view Im going to look at the current page&#8217;s action in the request context (rc) and figure out what the corresponding &#8220;view&#8221; is based on the action<\/li>\n<li>I&#8217;m going to use cfdirectory to find the lastmodifieddate of the view file from step 2.<\/li>\n<\/ol>\n<p>Without further adieu:<\/p>\n<p><code><br \/>\n<\/code>&lt;!&#8212; Start with the path to our views folder &#8212;&gt;<br \/>\n&lt;cfset local.viewPath=&#8221;#VARIABLES.FRAMEWORK.BASE#views&#8221; \/&gt;<br \/>\n&lt;!&#8212; Make an array of rc.action (we use this to append subfolders) &#8212;&gt;<br \/>\n&lt;cfset local.arrAction=ListToArray(rc.action,&#8221;.&#8221;) \/&gt;<br \/>\n&lt;!&#8212; Set the counter to be 1 short of the action array len b\/c the last member will be our view page &#8212;&gt;<br \/>\n&lt;cfset local.counter=ArrayLen(local.arrAction)-1 \/&gt;<br \/>\n&lt;!&#8212; Set the last member of our action array to be our action page &#8212;&gt;<br \/>\n&lt;cfset local.viewPage=&#8221;#local.arrAction[ArrayLen(local.arrAction)]#.cfm&#8221; \/&gt;<br \/>\n&lt;!&#8212; Append any subfolders to our viewPath &#8212;&gt;<br \/>\n&lt;cfloop from=&#8221;1&#8243; to=&#8221;#local.counter#&#8221; index=&#8221;local.a&#8221;&gt;<br \/>\n&lt;cfset local.viewPath=&#8221;#local.viewPath#\/#local.arrAction[local.a]#&#8221; \/&gt;<br \/>\n&lt;\/cfloop&gt;<br \/>\n&lt;!&#8212; Look for our viewPage cfm file in our viewPath &#8212;&gt;<br \/>\n&lt;cfdirectory action=&#8221;list&#8221;<br \/>\ndirectory=&#8221;#ExpandPath(local.viewPath)#&#8221;<br \/>\nname=&#8221;qGetLastdateModified&#8221;<br \/>\nfilter=&#8221;#ListLast(local.viewPage, &#8220;\/&#8221;)#&#8221;&gt;<br \/>\n&lt;!&#8212; If we have a record count then calculate the last modified date &#8212;&gt;<br \/>\n&lt;cfif qGetLastdateModified.recordCount&gt;<br \/>\n&lt;cfset local.siteLastUpdated=&#8217;#DateFormat(qGetLastdateModified.dateLastModified,&#8221;long&#8221;)# at #TimeFormat(qGetLastdateModified.dateLastModified,&#8221;hh:mm:ss tt&#8221;)#&#8217; \/&gt;<br \/>\n&lt;cfelse&gt;<br \/>\n&lt;cfset local.siteLastUpdated=&#8221;unknown :- (&#8221; \/&gt;<br \/>\n&lt;\/cfif&gt;<br \/>\n&lt;cfoutput&gt;#local.siteLastUpdated#&lt;\/cfoutput&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disclaimer: I&#8217;m a total newb to FW\/1. There is most likely a better, or built in way to do this. Still with me?\u00a0 Ok.\u00a0 Here is the specification for this little ditty: The site I&#8217;m working on is mostly static. It is required (perhaps legally, definitely procedurally) that every page of the site must have &#8230; <a title=\"Add a last modified date to FW\/1 (Framework One) pages\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2011\/06\/add-a-last-modified-date-to-fw1-framework-one-pages\/\" aria-label=\"Read more about Add a last modified date to FW\/1 (Framework One) pages\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[48,30],"class_list":["post-305","post","type-post","status-publish","format-standard","hentry","category-developer","tag-coldfusion","tag-fw1"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-4V","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=305"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/305\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}