Welcome Guest, Not a member yet? Register   Sign In
Call model-class from view
#31

[eluser]TheFuzzy0ne[/eluser]
Sorry, but I don't understand the problem. Have you checked the user guide? CodeIgniter solves many problems, but not in the sense you're talking about. A man's tools are only as good as the man using them. If you don't like the way something works, improve on it. That's how CodeIgniter is designed to work.

As for frameworks, there are a lot out there to choose from, it depends on your needs. Personally, I recommend CodeIgniter (of course). It's neat, fast, easily extendible, but that's my preference. Also, it has one of the best documented thing I've seen (including most non-framework related docs).
#32

[eluser]juan1904[/eluser]
[quote author="TheFuzzy0ne" date="1242422309"]Sorry, but I don't understand the problem. Have you checked the user guide? CodeIgniter solves many problems, but not in the sense you're talking about. A man's tools are only as good as the man using them. If you don't like the way something works, improve on it. That's how CodeIgniter is designed to work.

As for frameworks, there are a lot out there to choose from, it depends on your needs. Personally, I recommend CodeIgniter (of course). It's neat, fast, easily extendible, but that's my preference. Also, it has one of the best documented thing I've seen (including most non-framework related docs).[/quote]

I agree that CodeIgniter got an incredible user guide and the code is very well documented, no doubt! That's the reason I downloaded CodeIgniter in the first place.

What I need to do is:

I got my login-form on every singel page of my website. That form shall call for the same Controller which validates the data and gives you 1) welcome message if you login successfully. 2) give you an error message if you fail. The content of the website shall be the same so I do not want you to get redirected to the mainpage or something. I don't know how to do this. If you know any code example or something I'd gladly look at it!
#33

[eluser]TheFuzzy0ne[/eluser]
I've already answered your question:

Call views from within views (have a main template that loads other templates such as header, navigation menu, content footer, etc...)
Create a model or library to return any data you need accessible on every request.
#34

[eluser]juan1904[/eluser]
So basically I need to to do something like this in every Controller:
$data['welcome_info'] = $this->login_model->welcome();

But if the login fails I want the validation_errors(); to show the errors in the view. But I can only do this if I call a view in the controller that the form calls for (in my case class user, function login).

How do I know which contentpage I need to load?
#35

[eluser]TheFuzzy0ne[/eluser]
The content template would be specified in your controller method.

I recommend you spend some time checking out [url="http://www.haughin.com/screencasts/"]this screencast by Elliot Haughin[/url]. It's about 10-15 minutes long, and shows you how to use views within views, and dynamically set the content. This should hopefully give you some idea of how to achieve what you want to do.

I haven't seen the entire series yet, but I'm going to. Elliot is an excellent teacher.
#36

[eluser]Dam1an[/eluser]
I think the link you meant was this one
Yours just points to an XML error (although that is where the videos themselves are stored, but you don't get a directory listing
#37

[eluser]TheFuzzy0ne[/eluser]
Whoops. Yes, that's the one. Thanks for pointing that out. I've adjusted my previous post to reflect the correct URL.
#38

[eluser]juan1904[/eluser]
[quote author="TheFuzzy0ne" date="1242495013"]The content template would be specified in your controller method.

I recommend you spend some time checking out [url="http://www.haughin.com/screencasts/"]this screencast by Elliot Haughin[/url]. It's about 10-15 minutes long, and shows you how to use views within views, and dynamically set the content. This should hopefully give you some idea of how to achieve what you want to do.

I haven't seen the entire series yet, but I'm going to. Elliot is an excellent teacher.[/quote]

I call for the template view in all controllers with different contents (dynamic pages) depending on which page my users are browsing. And I do not know which page they are browsing when they log in on my webpage. I am going to watch the videos, thank you.
#39

[eluser]TheFuzzy0ne[/eluser]
You do know. You know because of what method has been called, or the arguments supplied to your method.

Code:
class Blog extends Controller
{
    function Blog()
    {
        parent::Controller();
    }

    function view($page_num=0)
    {
        # In this case, you know what page the user is viewing because
        # of the $page_num. Probably not the best example, but hopefully
        # you can see where I'm coming from.
        # Let's say pages 1-10 are known to use template1.php and
        # anything above page 10 uses template2.php

        $data['template'] = ($page_num > 10) ? 'template2' : 'template1';
        $this->load->view('main_template', $data);
        
        # So now we have template1 being used for formatting the content
        # if the page number is 10 or below, and template2 being used if
        # the page number is more than 10.
    }
}
#40

[eluser]juan1904[/eluser]
So if my user are browsing the webpage http://localhost/myproject/players/statistics/ (which controller is class Players and function statistics). Then my user is logging in to his account (the login forms controller is class: Users, function: login). I still want him to browse http://localhost/myproject/players/statistics/.

In this case the user that is logging in is using the same function to log in every time but needs to send different dynamic page to the view. Shall I give an argument to my class: Users, function: login here or what?




Theme © iAndrew 2016 - Forum software by © MyBB