CHtml

Hello,

I have been using yii for my third project now and I just find that Chtml is incredible!

I would like to know what you would need to do in order to use the chtml in another website that is made without yii?

tips and ideas?

thank you!!

read the guide carefully : Using 3rd-Party Libraries

you can use yii as 3rd lib :




// change the following paths if necessary

$yii=dirname(__FILE__).'/../yii/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config); //note that here doesn't call the "run" method of the CWebApplication class




/**************************************************************/

// following use the component of yii as usual :

 $jsOptions = array(

            CJavaScript::quote('hi'),

            'yes'=>'js:function(){}'

        ) ;

        echo CJavaScript::encode($jsOptions);

		echo CHtml::textField('test','someValueString',array('class'=>'richEditor'));




it’s interesting :lol: , if you want use some class from your existing project :D :lol:

  |------------myExistingProj





  |------------theNewProj


                index.php


                 3rdLib


                    |----yii.inc

in your newProj 's entry file(index.php) trying include the yii.inc file to using the class from existingProj you may write your yii.inc such as following logic:




   <?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../yii/framework/yii.php';

$config=dirname(__FILE__).'/../../myExistingProj/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config);


//following   code is for testing

 $jsOptions = array(

            CJavaScript::quote('hi'),

            'yes'=>'js:function(){}'

        ) ;

        echo CJavaScript::encode($jsOptions);

		echo CHtml::textField('test','someValueString',array('class'=>'richEditor'));


		print_r(User::model()->findAll());