About
Hello! I’m Jonathon Hill, an avid PHP/MySQL/Javascript web developer. Welcome to my blog, where I document interesting solutions to problems, publish some of my projects, and talk about politics or anything else I fancy. I hope you enjoy my blog!
4 Comments
→
Hi Jonathon,
I really like some of your solutions to making things simpler when using CodeIgniter. On the subject, I was wondering if you had a preference for a simple way to include headers and footers in your views. I know you can either do views within views, but that just doesn’t feel right to me. Although the advantage is only having to use one line to call your views within a controller. The method of building your views within an action by calling each view seperately also doesn’t interest me, because I’m trying to adhere to the DRY principle. I’ve also seen a solution where you create your own MY_controller and build the view that way then inherit from all your other controllers.
Do you have a recommended way to include your common views that’s simple and doesn’t require you add multiple lines of code to each controller action? I’m trying to keep my view calling to one line within each action of the controller.
Thanks,
Lee
Hello Lee,
My preference on that is simply calling views within views. If there is data that must be passed to the header and footer globally, then I would try something like this:
Copy that to a file called MY_Loader.php and save it in your libraries folder as described in the user guide. Once that is done you can load data which will be passed to all views globally:
I have found that including views within views is aggravating without a helper function, so I wrote the Modularity plugin to help with that.
Sorry it took so long to answer, glad you’re enjoying my blog!
Best wishes,
Jonathon
hi,
I checked your jquery date/time picker post. Do you know if we can show the current and future time and not the past time? for example, If I select Aug 4th as date and assuming the time now is 9am, I want the timer picker to show only the time after 9am and notthing before that as it’s gone. I am trying to use this date/time picker as I am trying to work on a event based site.
please let me know if you have any idea. I got to know about the date restriction for the date picker from jquery.com site i.e. shows only current and future date and not the past date/year.
regards
please email me if you have any idea. thanks!