tony007
tony007

Reputation: 53

html templates in Yii

I'm new to Yii but I want to learn the best practices. For example, I have the following HTML:

<html>
<head></head>
<body>

<!-- begin header -->
<div id="header"></div>
<!-- end header -->

<!-- begin main -->
<div id="main"></div>
<!-- end main -->

<!-- begin footer -->
<div id="footer"></div>
<!-- end footer -->

</body>
</html>

I usually cut the portions of HTML and distributed them in different files so that I had something like this:

<html>
<head></head>
<body>

<!-- begin header -->
<?php require_once('header.php')?>
<!-- end header -->

<!-- begin main -->
<?php require_once('main.php')?>
<!-- end main -->

<!-- begin footer -->
<?php require_once('footer.php')?>
<!-- end footer -->

</body>
</html>

so that if I changed something in "header.php" was visualized in all the other templates that required the file, which is the correct way to do this in Yii?

thanks for your answers

Upvotes: 1

Views: 3418

Answers (2)

Oleg
Oleg

Reputation: 7387

......header here......
<?php echo $content; ?>
......footer here......

Read this first

Upvotes: 2

KyleVan
KyleVan

Reputation: 501

Everything in Yii is in the layout file under views->layouts->main.php. This is where you would handle all of the changes that take affect throughout the entire site. For more complex sites you can use multiple layouts, column layouts etc.

If you decide to use one of the multiple column layouts then they still refer back to the main layout for the header, footer, etc.

Upvotes: 1

Related Questions