foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
foxfirefey ([personal profile] foxfirefey) wrote in [site community profile] dw_dev2014-02-16 10:11 pm
Entry tags:

dw-nonfree overriding dw-free routing

I'm pretty sure this is a question for the magnificent [personal profile] exor674, but here goes:

Let's say I convert the index page over to controllers/TT--it has two different versions, one for dw-free and one for nonfree!

How would one override the dw-free controller and/or template with the dw-nonfree one? What if one only needed to replace the template but not the controller, or visa versa?

ETA: Later I might try experimenting with detecting if a "home-local.tt" exists or whatnot, but my initial attempts at translating those pages with dw-nonfree are running into an interesting snag! Logged in it loads fine, logged out, there's some magical redirect that keeps happening until it goes boom. I'm trying to trace through the code to see where this is happening but no luck so far.

ETA2: Okay, the redirect was me forgetting to add anonymous => 1 to the controller call, woo! For the home page that sends it into a never ending loop of despair instead of being obvious. So far experimentation proves that putting a template with the same name in the dw-nonfree/views overrides dw-free/views, which is very good I think!

ETA3: Confirmed that just putting a new Home.pm controller in dw-nonfree/cgi-bin/DW/Controller does not override the dw-freecgi-bin/DW/Controller/Home.pm one. Going to try [staff profile] fu's suggestion of hooks to add in extra variable content to the template rendering!
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2014-02-17 06:26 pm (UTC)(link)
Gaaa, this has finally come up! ;_;

Yeah, I was mostly going "la la la la sticking fingers in ears and pretending this never came up"

Uh, probably one way to do it would be adding replace_key=>... or whatever, and then DW::Controller->register_replacement(...) but that takes WORK and that's probably a "me" thing.

exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2014-02-17 06:32 pm (UTC)(link)
And yeah, with ->register_string, you *can* just re-register it [ but I don't think it's that great of an idea ]

With ->register_regex, yeeeeah. no! <3
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2014-02-17 06:34 pm (UTC)(link)
Probably a case of load order.


use DW::Controller::OldPage;

DW::Routing->....


Would probably work better.
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2014-02-17 06:57 pm (UTC)(link)
hooks! Re-registering is kinda... blah, I feel. And fragile.