我创建了一个基于yii的项目。我有一个视图,我们从数据库中显示数据。我想打印那个页面。我搜索并找到了用于打印的打印输出扩展程序,并复制了“打印”和“打印”。目录到/ protected / extensions,但是我们无法理解如何在我的视图页面上使用它来打印它。
我的观点页面:
<div class="row">
<div class="row-column1">
<?php echo CHtml::label('Reg. Number. :','student_enroll_no'); ?>
<?php echo $info->student_enroll_no;?>
</div>
<div class="row-column2">
<?php echo CHtml::label('Adm. Date :','student_adm_date'); ?>
<?php if($info->student_adm_date != NULL)
echo date('d-m-Y',strtotime($info->student_adm_date));?>
</div>
</div>
<div class="row">
<div class="row-column1">
<?php echo CHtml::label('Student Name :','student_first_name'); ?>
<?php echo $info->student_first_name;?>
</div>
<div class="row-column2">
<?php echo CHtml::label('Enroll No. :','student_mobile_no'); ?>
<?php echo $info->student_mobile_no;?>
</div>
</div>
<div class="row">
<div class="row-column1">
<?php echo CHtml::label('Fathers Name :','student_last_name'); ?>
<?php echo $info->student_last_name;?>
<!--<?php echo CHtml::label('Gender :','student_gender'); ?>
<?php echo $info->student_gender;?>-->
</div>
<div class="row-column3">
<?php echo CHtml::label('Mothers Name :','student_mother_name'); ?>
<?php echo $info->student_mother_name;?>
<!-- <?php echo CHtml::label('Date of Birth :','student_dob'); ?>
<?php if($info->student_dob != NULL)
echo date('d-m-Y',strtotime($info->student_dob));?>-->
</div>
</div>
<div class="row">
<div class="row-column1">
<?php echo CHtml::label('Gender :','student_gender'); ?>
<?php echo $info->student_gender;?>
<!--<?php echo CHtml::label('Course :','student_transaction_course_id'); ?>
<?php
echo !empty($model->student_transaction_course_id) ? $model->relCourse->course_name : 'N/A';
?>-->
</div>
<div class="row-column2">
<?php echo CHtml::label('Date of Birth :','student_dob'); ?>
<?php if($info->student_dob != NULL)
echo date('d-m-Y',strtotime($info->student_dob));?>
<!--<?php echo CHtml::label('Year :','student_academic_term_period_tran_id'); ?>
<?php echo $model->Rel_student_academic_terms_period_name->academic_term_period;?>-->
</div>
</div>
<div class="row">
<div class="row-column1">
<?php echo CHtml::label('Category :','title'); ?>
<?php echo $info->title;?>
</div>
<div class="row-column2">
<?php echo CHtml::label('Email ID :','student_email_id_1'); ?> <?php echo $info->student_email_id_1; ?>
</div>
</div>
<div class="row">
<div class="row-left">
<?php echo CHtml::label('Course :','student_transaction_course_id'); ?>
<?php
echo !empty($model->student_transaction_course_id) ? $model->relCourse->course_name : 'N/A';
?>
<!-- <?php echo CHtml::label('Blood Group :','student_living_status'); ?>
<?php echo $info->student_living_status; ?>-->
</div>
<div class="row-column3">
<!-- <?php echo CHtml::label('Nationality :','student_transaction_nationality_id'); ?>
<?php if($model->student_transaction_nationality_id!=null)
echo $model->Rel_Nationality->nationality_name;
?>-->
<?php echo CHtml::label('Year :','student_academic_term_period_tran_id'); ?>
<?php echo $model->Rel_student_academic_terms_period_name->academic_term_period;?>
</div>
</div>
<div class="row">
<div class="row-left">
<?php echo CHtml::label('Subjects :','languages_known1'); ?>
<?php
$knwLang = "";
if($lang->languages_known1)
$knwLang = $lang->Rel_Langs1->languages_name;
if($lang->languages_known2)
$knwLang .= ", ".$lang->Rel_Langs2->languages_name;
if($lang->languages_known3)
$knwLang .= ", ".$lang->Rel_Langs3->languages_name;
echo $knwLang;
?>
</div>
</div>
<div class="row last">
<?php echo ('_____________________Note -Click on edit and update DoB , Subjects and upload photo ,Enroll no. .'); ?>
</div>
答案 0 :(得分:0)
此扩展程序的文档说明它已针对dataGrid小部件进行了调整。但是,您似乎没有使用dataGrid小部件,因此您可以执行的操作是覆盖默认的printedElement属性。
例如:
将您要打印的所有元素包裹在div中,并为其指定#printme,并将以下内容添加到您的视图中。
<?php
$this->widget('application.extensions.print.printWidget', array(
'cssFile' => 'print.css',
'printedElement'=>'#printme',
)
)
);
?>
注意:不要忘记添加/编辑print.css文件。
阅读文档以获取更多选项: http://www.yiiframework.com/extension/printout