Difference between page and view


My question is maybe silly but I can find the exact answer nowhere. I read documentation and can't find any information about the difference between pages and views.

I can see that more advanced plugins (tidypics for example) have two directories called 'views' and 'pages'. I know views - from the model MVC - covered in the documentation. But what are these 'pages' exactly?

For example I can see tidypics/pages/world.php. This file generates some html output (however there is no HTML used directly in this file) - just like a view. Could I use a view instead of that 'page'? Tidypics has some 'views' also...

When to use a 'page' and when a 'view'? I would appreciate anybody putting some light onto this problem.


  • A view is a component that can be used to create a page. The sidebar is a view. The header is a view.

    The "pages" are the controller in the MVC. The request for the page is routed through Elgg to a page handler (the first part of the controller). The page handler could pull in the views to create the page or it could include an extrenal page script. Most of the original Elgg plugins put most of the controller logic into these separate page scripts.

    Tidypics has a better code layout than most of those original plugins but putting the page controllers into a pages directory. (In the same way, action controller are in action directories.)

  • I would definitely encourage putting your pages into a separate pages directory and as well, isolating your model code into functions located in separate files (not embedded in action files for example). I usually put my model functions in a models directory (eg. models/model.php) although other plugins use a lib directory for the same purpose.

  • I got it. It is much more clear now. Thanks :)