4 Dec
2007

ModelGlue Version 3 – IN THE WORKS

I noticed Joe’s IM display name today, “MG3: Game On!” and asked him what was up. Here are the details he would reveal.

- 90% New Code.<br/>
- Backward Compatible (As much as possible.)<br/>
- Less Complicated (Some of the xml files may go away).<br/>

I don’t know about everybody else, but I am pumped. ModelGlue is without a doubt the best framework regardless of language.

Go Joe Go!!

8 Sep
2007

Dynamic FCKEditor Style Configuration

So, I have a CMS that now has multiple sites that it is managing. When there was only one site, FCKEditor could be set up statically now I need to dynamically assign a EditorAreaCSS and StylesXmlPath. The EditorAreaCSS is simple I just pass the correct css file into the config like this:

 fckEditor.Config['EditorAreaCSS'] = ‘../styles/style.css’;

The next step was a dynamic xml file for fckstyles.xml. What I wanted to do is to parse the css file for each site and dynamically display these styles in the drop down. So here is what I came up with:

 <!—- fckstyles.xml.cfm —>
 <cfsetting enablecfoutputonly=true>
 <cfsetting showdebugoutput=false>
 <cfsilent>
 <cffile action=”read” file=”#ExpandPath(‘../Path/To/File/css/display.css’)#” variable=”css” />
 <cfoutput>
 <cfset variables.count= 0 />
 <cfset variables.styleList = “” />
 <cfloop list=”#css#” delimiters=”{” index=”i”>
 <cfset variables.count = variables.count + 1 />
 <cfif variables.count eq 1>
 <cfset variables.styleList = i />
 <cfelse>
 <cftry>
 <cfset variables.thisClass = ListGetAt(ListGetAt(i,2,’}'),2,’.') />
 <cfif FindNoCase(‘:’,variables.thisClass)>
 <cfset variables.thisClass = ListGetAt(variables.thisClass,1,’:') />
 <cfif FindNoCase(‘ ‘,variables.thisClass)>
 <cfset variables.thisClass = ListGetAt(variables.thisClass,1,’ ‘) />
 </cfif>
 <cfelse>
 <cfif FindNoCase(‘ ‘,variables.thisClass)>
 <cfset variables.thisClass = ListGetAt(variables.thisClass,1,’ ‘) />
 </cfif>
 </cfif>
 <cfif not ListFind(variables.styleList,variables.thisClass)>
 <cfset variables.styleList = trim(variables.styleList) & ‘,’ & trim(variables.thisClass) />
 </cfif>
 <cfcatch type=”any”>
 <!– fail silently —>
 </cfcatch>
 </cftry>
 </cfif>
 </cfloop>
 <cfset variables.ignoreList = “body” />
 <cfsavecontent variable=”FCKStyles”><?xml version=”1.0? encoding=”utf-8? ?>
 <Styles>
 <cfloop list=”#variables.styleList#” index=”thisClass”>
 <cfif not ListFindNoCase(variables.ignoreList,thisClass)>
 <Style name=”#thisClass#” element=”div”>
 <Attribute name=”class” value=”#thisClass#” />
 </Style>
 </cfif>
 </cfloop>
 </Styles>
 </cfsavecontent>
 </cfoutput>
 </cfsilent>
 <cfcontent type=”text/xml” reset=”true”><cfoutput>#FCKStyles#</cfoutput>

One of the keys is to rename the file with a .cfm extensions. This allows ColdFusion to process it. Once the file in generating correctly, you simply pass in that path.

 fckEditor.Config['StylesXmlPath'] = ‘#basePath#fckstyles.xml.cfm’;

I hope this helps.

Follow Me!

Follow Me! Follow Me! Follow Me! Follow Me!