Pasang Title, Style dan JS di ZENDFRAMEWORK 1.12

Cara untuk memasangkan title, style css dan javascript bisa secara langsung di html file. Namu zendframework juga menyediakan caranya sendiri, yakni dengan memanfaatkan file di bootstrap. langkah-langkah nya adalah sebagai berikut.

Buka file application/bootstrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}

lalau masukan kode seperti dibawah ini.

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initPlaceholders()
{
// Set Doctype
$this->bootstrap(‘View’);
$view = $this->getResource(‘View’);
$view->doctype(‘XHTML1_STRICT’);

// Set the initial title and separator:
$view->headTitle(‘Header Layout’);
// ->setSeparator(‘ :: ‘);

// Set the initial stylesheet:
$view->headLink()->prependStylesheet(‘/layout/css/style.css’) // style
->prependStylesheet(‘/bootstrap-3.3.4/css/bootstrap.min.css’) // botstrap
->prependStylesheet(‘/bootstrap-3.3.4/css/bootstrap-theme.min.css’); // botstrap

// Set the initial JS to load:
$view->headScript()->prependFile(‘/flot/jquery.flot.categories.js’) // flot
->prependFile(‘/flot/jquery.flot.js’) // flot
// ->prependFile(‘/jquery.numeric/jquery.numeric.js’) //
->prependFile(‘/jquery.numeric/jquery.numeric.min.js’) // jquery numeric
->prependFile(‘/ckeditor/ckeditor.js’) // ckeditor
->prependFile(‘/bootstrap-3.3.4/js/bootstrap.min.js’) // botstrap
->prependFile(‘/jquery/jquery-2.0.0.min.js’); // jquery
}
}

Setelah itu tambahkan kode layout di file layout/scripts/layout.php

<?php echo $this->doctype() ?>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”shortcut icon” href=”<?php echo $this->baseUrl();?>/layout/images/favicon.ico” />
<?php echo $this->headTitle() . PHP_EOL ?>
<?php echo $this->headLink() . PHP_EOL ?>
<?php echo $this->headScript() . PHP_EOL ?>

</head>

dst …

Selesai.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s