View Single Post
ישן 11-03-09, 21:35   # 1
vadimg88
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
גיל: 37
הודעות: 710

vadimg88 לא מחובר  

אני משתמש בזה:

PHP קוד:
public function renderInternal($_viewFile_,$_data_=null,$_return_=false)
    {
        
// we use special variable names here to avoid conflict when extracting data
        
if(is_array($_data_))
            
extract($_data_,EXTR_PREFIX_SAME,'data');
        else
            
$data=$_data_;
        if(
$_return_)
        {
            
ob_start();
            
ob_implicit_flush(false);
            require(
$_viewFile_);
            return 
ob_get_clean();
        }
        else
            require(
$_viewFile_);
    } 
ואז השימוש:

PHP קוד:
$this->renderInternal('something.phtml', array('somevar' => $var)); 
ואז בקובץ phtml אני עושה:

PHP קוד:
<!-- some html here -->
<?php echo $somevar?>
<!-- some html here -->
  Reply With Quote