Welcome Guest, Not a member yet? Register   Sign In
Page Structure
#1

[eluser]CMCDragonkai[/eluser]
Hello,

I just need some clarification on this problem:
I understand controllers can be considered the pages in a website that people access. But a controller can have multiple methods.

My previous idea for constructing a new site, is for an "area" to be a class, and the class's methods would be individual pages but these pages are closely linked in style since they are in the same "area".

However, from the tutorials I have done, each method in a class essentially performs some task, but the page itself (that is determined from the class) remains the same.

Therefore, does that mean I will need a controller corresponding for every single page, a website might have. Like "about", "search", "products"... etc.

Furthermore, if one page has multiple functions such as a search page, you may have different options in the search form, then these should be handled like methods in the search class.


How do the pros set out their pages?
Thanks for any help.
#2

[eluser]techgnome[/eluser]
In my case, even my one-off single pages still had a context of belonging to the site... so I created my default controller as "site" and put them in there. I'm far from a professional though. You could also use the Routes table settings to perform some redirection so that example.com/about_us can be routed to example.com/site/about_us or what ever. It's something I haven't gotten around to exploring just yet.

As for the search, it depends I suppose. Due to the nature of how my site is designed, I ended up with two "search" controllers.... "Browse" and "Search" with the browse being more complex than the search one.

-tg
#3

[eluser]jalalski[/eluser]
To extend your examples, if you have products, then I would have a product class with methods 'list', 'view', 'search' etc which correspond to methods of that controller:

class Product extends Controller {
function list()...
function view( $id )...
function search()...
};

which would be accessible via URLs:

index.php/product/list
index.php/product/view/23
index.php/product/search

and so on.

Models = data structures, nouns, objects in the system
Controllers = actions, verbs, functionality

jal
#4

[eluser]CMCDragonkai[/eluser]
So what do you suggest jal?
#5

[eluser]jalalski[/eluser]
[quote author="CMCDragonkai" date="1289209067"]So what do you suggest jal?[/quote]
wot i sed.
do you have a more specific question?
#6

[eluser]CMCDragonkai[/eluser]
Ok, so every one of pages shall have a controller.

I believe a page can contain multiple functions and hence multiple methods.

Thanks for the information.
#7

[eluser]jalalski[/eluser]
[quote author="CMCDragonkai" date="1289234289"]Ok, so every one of pages shall have a controller.[/quote]

I don't think that is a good idea really. A controller contains many methods, each of which would be a URL/page. Reread what I wrote before...
#8

[eluser]CMCDragonkai[/eluser]
I know what you mean. I think we are confusing our terms. Pages is such a mutable term. Of course my controllers will have multiple methods which will then display different things. It's just that these different things have to be closely related.
#9

[eluser]nuwanda[/eluser]
I'm a little confused by your question.

First, don't try to do too much with one controller. Be discrete. For your own sake.

The methods of a controller can all do slightly different things by way of preparing data for the view, but then you hand that data off to one view.

For instance, you may have a controller that handles a view that lists info about a user. Each method may generate certain data about the user but that data is passed to the same view. The data that is passed to the view is handled by the view and is displayed depending on the data passed.
#10

[eluser]CMCDragonkai[/eluser]
You're right.

Anyway I need more experience in doing sites in the style of MVC. It's hard to visualise how a site is created when you've never done one using MVC.




Theme © iAndrew 2016 - Forum software by © MyBB