How can I make this controller DRY? |
I have been working on an online newspaper/blogging application with CodeIgniter 3.1.8 and Twitter Bootstrap 4. I am currently working on a lazy loading (of posts) feature.
I have added a pager option for the posts, to replace the pagination, if desired. The code in the controller responsible for this is: PHP Code: if ($this->Static_model->get_static_data()['has_pager']) { What is the most effective and DRY way to "externalize" the pager functionality (and the code above) and call it with a small piece of code, where it is nedded?
At first glance, I will suggest you move the code to a helper OR a separate controller OR another library that extends the default CI3 pagination library.
That way, you can load the file wherever it is needed. |
Welcome Guest, Not a member yet? Register Sign In |