Welcome Guest, Not a member yet? Register   Sign In
Question about the MVC pattern
#21

[eluser]Steve Grant[/eluser]
[quote author="wiredesignz" date="1215894659"]@Steve, Could you explain why you are calling CI_Base constructor from MY_Controller, while it extends the Controller class?

Also why you call the private method _ci_initialize()?[/quote]
Certainly can... I simply copy and pasted from the Controller class constructor ;-)

Quote:And Welcome to the forums too.
Thanks, I've been reading the forums for some time, having been using CI for nearly a year, but now feel confident enough to answer questions posed by others Big Grin
#22

[eluser]wiredesignz[/eluser]
I think the correct definition for the MY_Controller extension is:
Code:
class MY_Controller extends Controller
{
    function MY_Controller()
    {
        parent::Controller();
    }
}
Just so we don't confuse people.
All other class extensions follow the same pattern.
#23

[eluser]Randy Casburn[/eluser]
[quote author="loathsome" date="1215893370"]Superb, thanks a bunch for the very helpful and informative replies.

Please feel free to tell me exactly how you would solve this!

[/quote]

You're operating on the assumption that the pronoun "this" is easily extrapolated since you already know the whole of "this". Therefore, everyone else must intrinsically know what "this" is through osmosis.

Forgive me if I sound like a fool if I cannot give a solution for [ exactly how I would solve "this" ].

You'll get lots of answers from folks in this forum based on the presumptive information you've provided. Some more depth would be helpful.

Randy
#24

[eluser]loathsome[/eluser]
Isn't this explained detailed enough?
Quote:I can tell you one of the things we’re doing—on every page, there will be shown an information/"Status" box. This fetches data from a MySQL-table (but only every 10 minutes to save load). This box is shown everywhere, except on the about/ page. When using the model directly in the view, we had a if($!hide_status){ $this->model->blabla } statement, so we could easily hide the box by passing $data[’hide_status’] = true to the view page. Right now we’re seriously considering Steve’s solution, and it looks like we’re going with his.

If not, I'm not sure what more I could say. Please advise me.
#25

[eluser]Randy Casburn[/eluser]
@loathsome -- rather than me brandishing the sword blind folded, why don't I just tell you how I build my castles ;-) [ just trying to bring some humor to this ]

Here is the way I solve this type of...

Quote:I have this status thingy that updates every so often on every page and yada yada yada...

That doesn't mean it is the only way, the best, way, or even a good way.

I use AJAX extensively. I use AJAX extensively because of things like this. Asynchronous calls back to specialized controllers that handle security specifically designed for AJAX requests, pull data directly from models designed specifically for formulating data as JSON responses. I made a conscience DESIGN decision to break the MVC chain (please forgive me wirebydesignz) by having my JSON responses echo directly out of my models back to my calling pages.

Here is a post that sort of lays out the sequence http://ellislab.com/forums/viewreply/423884/

If you don't know what AJAX is or don't know what JSON is or what asynchronous page updates are there are lots of posts in these forums to help.

Now if you start to think about designing your system with these types of capabilities, you might think about sending "server load" indicators with your JSON data. That might lead to you applying the ability of adjusting the call-to-server timing based upon the "server load" characteristics. So now you are strapped to "10 minute" updates, but maybe the status is now one of those "sliding window" things you studied about in college (maybe last week or last year or in 1990 or not ever Smile ). You can adjust it on-the-fly.

I'm not saying this is good, bad, right, wrong, better, worse, up or down. I'm just saying this is how I solve similar dillemmas. Maybe you'll find this more helpful than my previous posts.

Randy
#26

[eluser]wiredesignz[/eluser]
@loathsome, You seem to have reached a point where Modular Extensions - HMVC would provide a solution for you.

While Randy uses Ajax calls to render his partial by calling a controller from his view remotely, ME allows you to create a module that you can call to build partial views such as your status box at server level.

Code:
<?php echo modules::run('status', $data, 'render'); ?>

@randy, I forgive you. But I don't recommend HTML output from models, you could just as easily load and return a view. Wink
#27

[eluser]Randy Casburn[/eluser]
@wired -- promote promote promote - I swear your going commercial any day now. Just like ExtJS! hehehhehehe Get everyone on board and...

Anyway -
Quote:@randy, I forgive you. But I don’t recommend HTML output from models, you could just as easily load and return a view. wink

I know you don't. That's why I said what I did. It is also a carefully crafted design decision, knowing in advance that I am bending the rules. Unlike most, I'm fairly careful about keeping things straight. I'll demonstrate in a minute. But first, the design thingy just for fun...

Why on the green green pastures of Antarctica would I want to drive to Noviscotia in order to get to Brazil? I have no need for the output class, nor all the calls along the way that it takes to get output that CI won't format for me along the anyway (search JSON in the UG). So your postulation would have me create a JSON encoded string that CI, in all of it's graces, would hand from one object to the next through the object hierarchy until getting dumped back to the output object where it will get sent to the browser -- my objective in the first place. So what did CI do with it? Nothing.

Now back to the "I'm careful about design stuff." The sequence diagrams are too large to upload into the forums space, but this model should give you an idea of how I keep track of design issues with CI and other platforms.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB