Welcome Guest, Not a member yet? Register   Sign In
[split] Advanced URI routing etc

(This post was last modified: 05-26-2015, 10:11 PM by ciadmin.)

Advanded URI routing (like this http://yiiframework.ru/doc/guide/en/topics.url) instead of filesystem-based routing with overriding in config/routes.php. It's a good and modern practice nowadays - more securely, less pages-based (so I would give names like "Rest_Api" for my controllers, and call it with a whole bunch URLS in Django/YII way).

Form-validation system is amazing, but very out-of-date stuff in AJAX/SPA era.

Also I see a lack of things linked with js/css minification and so on. I see it like this:

Instead of <head>....</head> I offer to make some library-based system enabled by default. When your're in controller code, you may do something like this:

1 $this->load->library('Layout');
2 $this->Layout->title = 'My simple web page';
3 $this->Layout->meta->description = 'Info about this page'
4 $this->Layout->meta->keywords = 'codeigniter is alive';
...and other meta, .og sttff. etc
5 $this->Layout->js->add_url('http://13.storage.com/js_min12.js');
6 $this->Layout->js->remove_url('http://13.storage.com/js_misc_min12.js'); //if auto-loaded, but not needed on specific page
7 $this->Layout->css->add_css('style.css');
8 $this->Layout->css->add_css('bootstrap.css');
9 $this->Layout->css->remove_css('bootstrap.css');
10 $this->Layout->js->add_text('some google analytics snipper');
11) $this->Layout->js->add_var('foo', "['bar','baz','bad']");

Afterwards you just put <?=$this->library->generat_head_code()?> between <HEAD> and </HEAD>, before that all js and css files had glued and minified and gziped. There's a lot of things to work with Layout class - caching, cache lifecycle...

I refactor some of my new CI project this way to get rid of spaghetti code. Any criticism to this approach is recommended>

Messages In This Thread
[split] Advanced URI routing etc - by Sashk - 05-26-2015, 08:57 PM
RE: [split] Advanced URI routing etc - by Sashk - 07-09-2015, 02:25 PM

Theme © iAndrew 2016 - Forum software by © MyBB