[Catalyst] Checking client browsers, best approach?

Peter Karman peter at peknet.com
Wed Sep 20 15:15:04 CEST 2006

Ryan scribbled on 9/20/06 7:44 AM:
> OK, here is what I need to do.  I'm writing a reservation system for a
> hotel and I have some cool features in mind for the process but they
> require javascript and "newer" browsers. What I was planning on doing is
> creating the bare-bones pages that work in any browser, no JS just all
> server calls etc...then I want to go back and insert the new stuff where
> it's appropriate but only for the people that can handle it.  I was
> thinking of having a landing page(default or something) that ran some
> tests to see if that could fail. Then I thought it might be easier in the
> begin function to just check browsers and set a variable in the stash if
> they can handle the new stuff or not. What's the best way to go about
> doing this, should I just scan the req variables that come in and make my
> decision on that or does Catalyst have something better?

I use C::Plugin::Browser and then check that in my templates for what fancy 
stuff to include.

In TT:

   [% IF c.request.browser.windows && c.request.browser.ie %]
    # do something
   [% END %]

I've also done similar to what you describe and set stash var in begin() method:

  if ($c->req->browser->windows && $c->req->browser.ie)

Peter Karman  .  http://peknet.com/  .  peter at peknet.com

More information about the Catalyst mailing list