yii framework : How to access a class inside a layout(/protected/views/layout) file?

StackOverflow https://stackoverflow.com/questions/22409440

  •  14-06-2023
  •  | 
  •  

문제

I have a class with some static helper methods. I want to use these methods from the layout file. These methods contain some common code used by all layout files. Even putting the class in 'components' folder does not solve the problem.

도움이 되었습니까?

해결책

You have to import the class before you can use it:

Yii::import('ext.components.YourClassName');
$class = new YourClassName;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top