Welcome Guest, Not a member yet? Register   Sign In
What's the right place to put this? Writing a CMS in CI.
#1

[eluser]simolokid[/eluser]
Hi!

I've been busy starting up a CMS project in CI, but I'm sort of stuck where I should put the every-page-has-this code.

I'm talking about the dynamic header menu, breadcrumbs, page keywords/description/author tags, dynamic footer and that sort of stuff.

I tried the MY_Controller way, but this results in copy-paste coding since i still have to call it in every_single_method_call.

Now I'm trying to use a hook, but the problem with that is that I need the data that the hook holds (all the needed data for the specific request), to get in my views.

I then came across the application flow page, and figured I'd give config items a shot. This worked wonders weren't it for the following:

In each method i have a
Code:
$data
array that holds the view data. Then i render that data. But this would require me to have the same line of code (assigning the config item array to the current data array) in every method that's in a controller (public ones ofcourse). Not very DRY.

Then I figured I could use multiple hooks of the type post_controller_constructor by multi-dimantionalising it.
Code:
$hooks[]['post_controller_constructor'] = ..
And since the second one (that is supposed to assign the current page-specific data to the view data array in the controller method is an index later, it'd grab everything and stuff would be awesome.

Problem with that? I haven't gotten the slightest clue how to assign the current array of page data to the view array.

Then i figured i'd skip the hook and try giving a data parameter to each function call in the controllers. the data parameter would be the page data and in the function call it'd do its magic, but this again, would be the same effect as the config item. A repetitive single line of code in each function.

How should I go about this? Is there a way to automate this? ;x

I should probably note, that to grab the current page-meta data (And for everything else database related) I'm using Doctrine, so I can't use pre_controller hooks as the libraries aren't loaded yet. (And I'm loving the autoload libraries array.)

Any help is greatly appreciated.


Messages In This Thread
What's the right place to put this? Writing a CMS in CI. - by El Forum - 05-26-2012, 04:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB