2011-09-16 14 views
0

私の/ publicディレクトリに/ cssと/ jsの下にいくつかのCSSファイルとJSファイルを追加しました。私のbootstrap.phpのファイルでは、私は以下の初期化子使用しています。私の見解ではZend_ViewのheadLink経由でCSSクラスを参照するには?

protected function _initPlaceholders() { 
    $view = new Zend_View($this->getOptions()); 
    $view->headLink()->appendStylesheet('/css/themes/gray/style.css'); 
    $view->headScript()->prependFile('/js/global.js'); 
    return $view; 
} 

を次のように、私はCSSやスクリプトを参照しています:

<?php 

echo "Employee Pay Stub Summary"; 
echo $this->headLink(); 
echo $this->headScript(); 
?> 

私の見解でラッパーDIVで次のように私のCSSのテーマの

<div id="wrapper"> 

<?php if(count($this->PayStub)): ?> 
<table> 
    <tr> 
    <th>Employee ID</th> 
    <th>PayStub ID</th> 
    <th>Earning Type</th> 
    <th>Total Hours</th> 
    <th>Hourly Rate</th> 
    <th>Total Earnings</th> 
    <th>Total Witholding</th> 
    <th>Start Date</th> 
    <th>End Date</th> 
    </tr> 


    <?php foreach ($this->PayStub as $key => $values):?> 
     <tr> 
     <td><?php echo $values['EmployeeID'];?></td> 
     <td><?php echo $values['PayStubID']; ?></td> 
     <td><?php echo $values['EarningType']; ?></td> 
     <td><?php echo $values['TotalHours']; ?></td> 
     <td><?php echo $values['HourlyRate']; ?></td> 
     <td><?php echo $values['TotalEarnings'];?></td> 
     <td><?php echo $values['TotalWitholding']; ?></td> 
     <td><?php echo $values['StartDate']; ?></td> 
     <td><?php echo $values['EndDate']; ?></td> 
     </tr> 
    <?php endforeach;?> 

</table> 

<a href="/index">Logout</a> 
<?php else: ?> 
    <p>There are no Paystubs available</p> 
<?php endif; ?> 
</div> 

一部は次のとおりです。

#wrapper > header { 
background-color: #ABCEEE; 
background-image: url(../../svg1910.svg?from=%23ABCEEE&amp;to=%238AA8CA); 
background-image: -o-linear-gradient(top, #ABCEEE, #8AA8CA); 
background-image: -ms-linear-gradient(top, #ABCEEE, #8AA8CA); 
background-image: -moz-linear-gradient(top, #ABCEEE, #8AA8CA); 
background-image: -webkit-gradient(linear, left top, left bottom, from(#ABCEEE), to(#8AA8CA)); 
background-image: -webkit-linear-gradient(top, #ABCEEE, #8AA8CA); 
background-image: linear-gradient(top, #ABCEEE, #8AA8CA); 
-pie-background: linear-gradient(top, #ABCEEE, #8AA8CA); 
} 

#main-navigation > li.active { 
background-color: #abceee; 
background-image: -o-linear-gradient(#ABC, rgba(234, 238, 243, 0.2) 10%, #ABCEEE), -o- 
linear-gradient(left, #ABC, #ABCEEE 3%, #ABCEEE 97%, #ABC); 
background-image: -ms-linear-gradient(#ABC, rgba(234, 238, 243, 0.2) 10%, #ABCEEE), -ms- 
linear-gradient(left, #ABC, #ABCEEE 3%, #ABCEEE 97%, #ABC); 
background-image: -moz-linear-gradient(#ABC, rgba(234, 238, 243, 0.2) 10%, #ABCEEE), -moz- linear-gradient(left, #ABC, #ABCEEE 3%, #ABCEEE 97%, #ABC); 
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ABC), 
color-stop(10%, rgba(234, 238, 243, 0.2)), color-stop(100%, #ABCEEE)), -webkit-gradient(linear, 
left 
center, right center, color-stop(0%, #ABC), color-stop(3%, #ABCEEE), color-stop(97%, #ABCEEE), 
color-stop(100%, #ABC)); 
background-image: -webkit-linear-gradient(#ABC, rgba(234, 238, 243, 0.2) 10%, #ABCEEE), - 
webkit-linear-gradient(left, #ABC, #ABCEEE 3%, #ABCEEE 97%, #ABC); 
background-image: linear-gradient(#ABC, rgba(234, 238, 243, 0.2) 10%, #ABCEEE), linear- 
gradient(left, #ABC, #ABCEEE 3%, #ABCEEE 97%, #ABC); 
} 

/** 
* Contents 
*/ 
#wrapper > section > section > header h1, 
#wrapper > section > section > .viewport > header h1{ 
color: #567; 
line-height: 30px; 
margin: 0; 
text-shadow: #FFF 0 1px 2px; 
} 
ここ

は、Firefoxのソースの表示出力です:

Employee Pay Stub Summary 
<div id="wrapper"> 

<table> 
    <tr> 
    <th>Employee ID</th> 
    <th>PayStub ID</th> 
    <th>Earning Type</th> 
    <th>Total Hours</th> 

    <th>Hourly Rate</th> 
    <th>Total Earnings</th> 
    <th>Total Witholding</th> 
    <th>Start Date</th> 
    <th>End Date</th> 
    </tr> 



       <tr> 
     <td>1</td> 
     <td>1</td> 
     <td>0</td> 
     <td>40</td> 
     <td>25</td> 

     <td>1000</td> 
     <td>100</td> 
     <td>07/01/2011</td> 
     <td>07/14/2011</td> 
     </tr> 
       <tr> 
     <td>1</td> 

     <td>5</td> 
     <td>1</td> 
     <td>80</td> 
     <td>40</td> 
     <td>3200</td> 
     <td>320</td> 

     <td>07/15/2011</td> 
     <td>07/31/2011</td> 
     </tr> 

</table> 

<a href="/index">Logout</a> 
</div> 

私はZFに新たなんだので、私は私が私の見解では、ヘッダーとラッパークラスを参照する方法がわからないんですか?同様に、そのディレクトリ内のファイルの1つからJS関数を呼び出すにはどうすればよいですか?上記の#wrapper CSSスニペットが私のビューのDIVによって正しく参照されるようにするにはどうすればよいですか?

ありがとうございます!

+0

ビュー内でヘッダーとラッパークラスを参照するとどういう意味ですか?これらのファイルの1つからjs関数を呼び出すには、ビューのどこにでもスクリプトタグを置き、関数を通常のように呼び出します。通常は、レイアウトにheadLinkとheadScriptをエコーし​​たいのですが、これは通常タグのところにあるからです。 – drew010

+0

htmlで何かを使用したい

....
DIVと参照CSSクラスを私のビューの中に置くことができますか、このタイプのCSS参照を扱う特別な方法がありますか? – SidC

答えて

0

あなたはあなたのビューではJavaScriptと同じあなたは、通常のHTMLページの場合と同じように、CSSクラスを参照することができます。

headScript()を使用するとheadLinkは()ヘルパーはちょうどあなたが含まれたいファイルを追加または付加する支援されています。

たとえば、私のレイアウトスクリプトでは、自分のサイトでEVERYWHEREと使用されるいくつかのCSSとjavascriptファイルを前に付けています。レイアウトのタグではheadLink()とheadScript()をエコーし​​ますが、私は追加のコードを必要とするかもしれない個々のビューからCSSとjavascriptファイルを追加することができます。私のビューから余分なファイルを追加することで、私のレイアウトがheadScriptとheadLinkをエコーし​​たとき、私は自分のビューから追加した追加のファイルを取得します。

彼らはちょうどヘルパーですが、通常のJavaScriptコードまたはリファレンスCSSと呼ばれる方法を変更しません。

これらのクラスを含むCSSファイルを含めると、ビューのどこでも使用できます。ここで

は私のレイアウトスクリプトからの抜粋です:

<?php echo $this->doctype() ?> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 
<head profile="http://gmpg.org/xfn/11"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> 
<?php echo $this->headTitle() ?> 

<?php 
$this->headLink() 
    ->prependStylesheet($this->baseUrl('css/master.css')) 
    ->prependStylesheet($this->baseUrl('css/application.css')); 

echo $this->headLink(); 
?> 

<?php 
$this->headScript() 
    ->prependFile($this->baseUrl('js/prototype.js'), 'text/javascript'); 
echo $this->headScript(); 
?> 
</head> 

そして、特別なJavaScriptとCSSファイルを必要とする別のビュースクリプトから、私は

<?php 
$this->headScript->appendFile($this->baseUrl('js/prototip.js'), 'text/javascript'); 
$this->headLink->appendStylesheet($this->baseUrl('css/prototip.js')); 
?> 

を追加今私のレイアウトは、これらの追加ファイルを持っています。レイアウトと表示がレンダリングされたら、

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 
<head profile="http://gmpg.org/xfn/11"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> 
<title>Site Title</title> 
<link href="/css/application.css" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/css/master.css" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/css/prototip.css" media="screen" rel="stylesheet" type="text/css" /> 

<script type="text/javascript" src="/js/prototype.js"></script> 
<script type="text/javascript" src="/js/prototip.js"></script> 
</head> 

ブラウザでHTMLとJavaScriptがどのように動作するかはまったく変わりません。

+0

私の質問が更新されました。ラッパーのCSSスニペットがDIVによってレンダリングされていません。あなたはレイアウトを使って言及しましたが、ビューを使うよりも良い/悪いですか? – SidC

+0

レイアウトは基本的にはビュースクリプトですが、すべてのコンテンツを包むラッパーです。私は確かにレイアウトを使用することをお勧めします。ブラウザーでページにアクセスしてpastebinに投稿したときに、ページの完全な出力結果を表示できますか?問題は最終的な文書の構造に過ぎないと思う。 – drew010

関連する問題