Standardization of the site

The question was asked: 6 years 9 months ago   views: 25
0

Tell me, how to implement the standardization of the site??? In the database there is a row id : link : page : template so it is necessary that in a template record record template.

For example:

id=1 : link=localhost : page=main : template=mytheme

id=2 : link=localhost/about/ : page=About : template=mythem2

Answers   3

0

That's what I use:

function view($view_name, $data = Array())
{
extract($data);
include(INC.'/view/'.$view_name.'.php');
}

That is just for templates using the file with the correct markup and inserts short tags PHP. It may not be perfect, but it's still easier to any fancy template engines and I do not have any cons. When the controller worked through the model needs data, it calls the function view, view name, and, if necessary, the parameters will be inserted where necessary.

Here is an example of a simple controller:

loadModel('profile'); // the loaded model for working with data, user profile
$data = Profile::get($_SESSION['id']); // using the model downloadable data for the current user
view('profile', $data); // download profile template, passing it the data

And in the template there will be usathese in the right places the data passed to it. This is a very simple example.

Answered: Олег Архипов Олег Архипов 04-07-2012 в 14:16:43
And how then to make a selection template for a particular page. For example, the home page template No. 5 contacts page-template number 6 ??? And not much is not clear where it's all stick ! - webkostya webkostya 04-07-2012 в 20:23:30
Well, it's a function, and it passes the parameter $view_name (view name) out there and write. what you need to open. And written this code in the page controller. Read about MVC. In General: the controller controls the behavior for this page, for example, takes the model, it requests the data, perhaps something that makes the subsidiary, causes the performance. - Олег Архипов Олег Архипов 04-07-2012 в 20:37:29
Maybe I misunderstood or not explained. But if it is short it is necessary that: In the DB there is a line id:link:page:template so that the template record record template. For example: id=1:link=localhost:page=main:template=mytheme id=2:link=localhost/about/:page=About:template=mythem2 - webkostya webkostya 04-07-2012 в 20:59:24
Explained in Skype. - Олег Архипов Олег Архипов 04-07-2012 в 22:06:51
0

Look for starters on shirokolistvennye Smarty as template engine.

Answered: PashaPash PashaPash 03-07-2012 в 12:34:03
0

Standardization is a very useful technology that allows you to separate development of parts of the site. For example, designers only have access to CSS/HTML code, less JS, and they have no idea about how to work with what they moderate and modify at all. With the so-called "technologists" that's the same: I have access only to the implementation of functional - PHP code, for example. All this you of course know, but this is how the entry of something =) And now to business.

To implement the standardization as you like! The simplest looks like this:

file 1 - functional1.php - "half" of the site, along with all the styles etc
file 2 - functional2.php - the second "half" of the site, along with all the styles etc

Page1:

include("functional1.php");
 echo "Some text";
 // other functional
include("functional2.php");

Page2:

include("functional1.php");
 echo "New text again!";
 // new - > other functional again!
include("functional2.php");

As you can see, you can implement standardization in a simple way: write some code that implements basic functionality, styles, other stuff, etc, then split the file "in half", so to speak, what the split should happen in the place where you plan to display some information to implement a functionality to write new styles, etc. and finally "sculpt" each new page, as shown above.

A more complex form takes the templating engine, implemented in the classroom. These template engines are much more flexible, in some ways even more reliable, but often you can do without it( though not always, but often! ) - enough flexibility first, easier.

Answered: AseN AseN 03-07-2012 в 20:02:50