Plugins: Accessing working project's models and projects.

0 views
Skip to first unread message

Joe

unread,
Jan 3, 2011, 8:47:06 PM1/3/11
to ColdMVC
So I am working with plugins alot lately and have a few questions.
Plugins, to me are snippets that are available across projects. If
this is the case, sometimes I will want to use a model that is inside
the project I am working on it. Example: I am working on a clipboard
plugin that I want to use across projects. The problem I am running
into is that sometimes there will be a "User" model and others not. Is
there way to check if a model exists and also if a property exists on
that model. Example, I am trying to do the following and don't know
how:

This is peusdo code...
<cfif $.model.exists("User")>

<cfset var user = $.model.get("User")/>
<cfset user = user.get($.user.id())/>

<cfif $.property.exists(user,"clipboard")>

<!--- some code --->

</cfif>

</cfif>

I am using the $ because I feel like these should exists in the
helpers. I think the model helper functions that I am showing above do
exist, but I don't think the property ones do. Any ideas on how I can
do something similar to do this?

Tony Nelson

unread,
Jan 3, 2011, 10:23:44 PM1/3/11
to ColdMVC
I recently re-worked the model helper into a modelManager component in
an effort to reduce the number of global components. I believe you
should be able to something like the following:

/**
* @accessors true
*/
component {
property modelManager;

function doSomething() {
if (modelManager.modelExists("User") &&
modelManager.hasProperty("User", "firstName")) {
... {code} ...
}
}
}

-Tony

Joe

unread,
Jan 3, 2011, 10:49:57 PM1/3/11
to ColdMVC
I meant this post's title to be "properties" not "projects".
Misspelling on my part. Thanks I will check out a new copy and try it
out.
Reply all
Reply to author
Forward
0 new messages