Anyone know how to hack this?

19 views
Skip to first unread message

raulriera

unread,
Dec 8, 2009, 7:48:04 PM12/8/09
to ColdFusion on Wheels
Has anyone been able to call Wheels API from a custom tag? I am in
NEED of this hehe

Per Djurner

unread,
Dec 9, 2009, 3:41:35 AM12/9/09
to cfwh...@googlegroups.com
I think you can use the "caller" scope from within the custom tag:
caller.paginationLinks() for example.

On Wed, Dec 9, 2009 at 1:48 AM, raulriera <rier...@gmail.com> wrote:
> Has anyone been able to call Wheels API from a custom tag? I am in
> NEED of this hehe
>
> --
>
> You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
> To post to this group, send email to cfwh...@googlegroups.com.
> To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
>
>
>

raulriera

unread,
Dec 9, 2009, 9:28:06 AM12/9/09
to ColdFusion on Wheels
Tried that, no luck :( the weird thing i that I dump the caller object
and I see all the wheels functions in there

Andy Bellenie

unread,
Dec 9, 2009, 9:39:59 AM12/9/09
to cfwh...@googlegroups.com
How come you need to use a custom tag? They're, like, sooooo cf5 :)

Russ Johnson

unread,
Dec 9, 2009, 9:46:59 AM12/9/09
to cfwh...@googlegroups.com
Custom tags still have alot of valid uses. Although I never thought I would say that. I went probably 6 years without ever writing one and mostly just using UDF's for that stuff.

I ran into the same issue Raul is having once and if Im right, its on the same project ;) I was never able to get it to work either.

joshua clingenpeel

unread,
Dec 9, 2009, 10:16:09 AM12/9/09
to cfwh...@googlegroups.com
Custom tags are totally coming back. I believe the cfspec guys use
them as a way to create their mini-DSL. It's an interesting use for
them.
--
Josh

Randy Johnson

unread,
Dec 9, 2009, 10:20:14 AM12/9/09
to cfwh...@googlegroups.com
Have there been improvements with custom tags?  I thought I heard before that your app takes a performance hit with custom tags for one reason or another? I have never really used them.  I think I created 1 custom tag before when I was integrating paypal credit card API.

Randy

Per Djurner

unread,
Dec 9, 2009, 10:25:13 AM12/9/09
to cfwh...@googlegroups.com
What if you pass in a reference to the method as a parameter to the custom tag?
myTag(myMethod=variables.paginationLinks)

Russ Johnson

unread,
Dec 9, 2009, 10:33:32 AM12/9/09
to cfwh...@googlegroups.com
Thats exactly what we use them for in SplashCMS.. we have created a mini-DSL called SplashTags that allow you to work with the content in other files. Works really well. Much better than the old way I was doing it. A custom tag is much easier to write than trying to parse the dsl out of the content, extract the arguments and then you still have to process them..

The custom tags work as an imported tag library so you can just put <s:snippet name="header"> in the conten and the snippet custom tag is called to process it. Simple!

What would be great though is if we had access to use the wheels model calls to get the snippet. Currently we are just having to write queries to get the data since we cant access the wheels functions in the custom tags.

raulriera

unread,
Dec 9, 2009, 11:11:15 AM12/9/09
to ColdFusion on Wheels
I have to try that Per, I'll post updates

Indy Nagpal

unread,
Dec 9, 2009, 12:09:25 PM12/9/09
to cfwh...@googlegroups.com
Ya. Custom tags are pretty good for things like that. If you look at MangoBlog, it also uses them similarly. Works very well.

raulriera

unread,
Dec 9, 2009, 12:19:03 PM12/9/09
to ColdFusion on Wheels
Sadly it doesn't work

<s:gallery test="#variables.paginationLinks()#" /> But for some
magical reason I have access to them on the "Layouts" of the CMS and
not on the Pages

Russ Johnson

unread,
Dec 9, 2009, 12:26:07 PM12/9/09
to cfwh...@googlegroups.com
Raul, this might be due to the way the content is being rendered. When dealing with nested custom tags, you have to extra mindful of scope. In the Layouts of Splash, you probably have access to them because they are the top level rendered item.

Remember, the layout file gets included, then the Splash tag for the page gets rendered. So the caller of the page tag is the layout file. Im pretty sure that wont work. You can try to dump the caller scope in the page element to see what you get but Im willing to bet you will have to go farther up the scope chain to get at what you want when working in a page element. Snippets will probably be the same way but could be even trickier since they could be included from a layout or a page.

You might want to consider pushing the wheels elements you want access to into the request scope then any of the tags should be able to access them. That was one of the original intents of the request scope way back in CF 4.5 I think when it was introduced.

- Russ

Per Djurner

unread,
Dec 9, 2009, 12:41:22 PM12/9/09
to cfwh...@googlegroups.com
Did you try without the parentheses too?

raulriera

unread,
Dec 9, 2009, 12:50:24 PM12/9/09
to ColdFusion on Wheels
Yeah I did, still no luck... oh well... on to something else I
guess :P

raulriera

unread,
Dec 9, 2009, 5:58:20 PM12/9/09
to ColdFusion on Wheels
You are right Russ, on the Pages I can call "caller" and I have all
the wheels functions available, I wonder if I have to call
caller.caller (seems more like Actionscript this one) or just send
them via aarguments to the custom tag... will find out soon

Russ Johnson

unread,
Dec 9, 2009, 8:25:22 PM12/9/09
to cfwh...@googlegroups.com
I would still recommend pushing the stuff you want available into the request scope, then any of the custom tags can simply access it because they all have access to the request scope.

raulriera

unread,
Dec 9, 2009, 9:23:39 PM12/9/09
to ColdFusion on Wheels
Example? :)

Andy Bellenie

unread,
Dec 10, 2009, 4:30:02 AM12/10/09
to cfwh...@googlegroups.com
I'm still curious why a custom tag is a better solution than a cfc,
I'd appreciate someone pointing out the advantages.

2009/12/10 raulriera <rier...@gmail.com>:

Russ Johnson

unread,
Dec 10, 2009, 10:37:36 AM12/10/09
to cfwh...@googlegroups.com
Its not "specifically" better than a CFC. But for certain functions they work out better. Let me give you a practical example as to why I chose to use custom tags over CFC functions in one instance.

For this CMS I built, I wanted to have a mini-DSL for working with the content in the system. Sure I couldve written functions that could be called from within the content like this:

#snippet(name="header")#

However, even though us CF programmers understand making function calls, to most html/designer types they dont use functions. They understand tags. Its a much easier way to think, which is probably what dew ALOT of develoers into ColdFusion in the first place. Dont get me wrong, Im a big cfscript fan. But I wanted the templating language to be simple to learn which meant keeping it as close to what they understand as possible. So customtags was a perfect solution.

We write custom tags to work with the content such as building nav elements, pulling in snippets, etc. Then when each page call is processed. We simply do a cfimport and import the tag library into the page rendering process using the scope "s". So any tags that look like this:

<s:snippet name="header" />

Gets run by the corresponding custom tag from the import.

In this case its simply a matter of making it easier for the user.

In fact I the first version of Splash used a pretty complex parsing routing that pulled the specific tags out of the content to render them. It was a pain to write originally. After thinking about the custom tag solution, I whipped up the first test case in about 5 minutes and I was sold. It was MUCH easier to write the DSL in custom tags. It was much less error prone than using the CFC based parser.

So as I started this post, I dont think custom tags are "better" than functions, I just believe in using the best method for the specific task.

- Russ

raulriera

unread,
Dec 10, 2009, 10:40:30 AM12/10/09
to ColdFusion on Wheels
Mostly because this is meant for non CF savvy people... so <s:snippet
name="header" /> (suitable for web designers) is simpler that working
out some weird ColdFusion code which you don't nothing about. (that is
my reason though) and the open, closing and tagContent is pretty
useful to do some cool stuff too

On Dec 10, 5:30 am, Andy Bellenie <andybelle...@googlemail.com> wrote:
> I'm still curious why a custom tag is a better solution than a cfc,
> I'd appreciate someone pointing out the advantages.
>
> 2009/12/10 raulriera <rierar...@gmail.com>:

Mike Craig

unread,
Dec 10, 2009, 5:13:34 PM12/10/09
to cfwh...@googlegroups.com
I don't know about better...but there are some definite advantages like
being able to easily share settings across multiple tags and then use the
custom tags, imported via cfimport, to perform layouts while interacting
clearly with values, settings, etc. The key for some of my larger projects
is they work well as wrappers of code AND content so you can make, as per
suggested:

<s:layoutHeader mode="admin">
[do anything you want here]
<s:layoutNavigation/>
</s:layoutHeader>

When you hit the end tags, you can manipulate the content however you want
after the fact or just let the output happen...nesting comes in real handy
for this where the layoutNavigation tag above can understand settings made
in its parent. Plus you can easily embed your start / end divs so you cause
use blueprint css for layout...then later, create a whole new library set
for, say YUI, name the tags the same, and just swap from one library to
another.

Better? No...highly functional for teams who don't care how it lays out,
they just want to operate on the guts...definitely. The instructions are
much easier for newbies too.

Just my two-four cents...probably not a nickels worth...I love them but they
are not always the best solution.

Mike
Reply all
Reply to author
Forward
0 new messages