Hwangar
(Hwangar)
1
Hi guys,
I’m having a mess trying to figure out how to get URL’s from a certain public path (not in protected dir) or from a path alias…
Using Yii::getPathOfAlias I can get the physical path and I see UrlManager is more focuse on Controllers and Actions, etc, so …
someone can give me an idea?
Thx!
Hwangar
horizons
(Horizons Horizons)
2
I would just use your path directly from from the base url.
e.g.
$base_url=Yii::app()->baseUrl;
CHtml::cssFile($base_url.’/css/print.css’);
Or what "exactly" do you want to do?
phpdevmd
(Phpdevmd)
3
Is this of any use?
get current webpage in yii? how?
Hwangar
(Hwangar)
4
thx guys… in the code of my ImageApi extension I’d like to offer for the generated images 2 methods:
finally I’m using what horizons said removing the “webroot path” from the generated path and appending the “baseUrl” from Yii:
$targetPath = Yii::getPathOfAlias($preset['cacheIn']);
$generatedPath = $this->createPath($presetName, $file);
$webrootPath = Yii::getPathOfAlias('webroot');
if(strpos($generatedPath, $webrootPath) !== FALSE) {
$generatedPath = substr($generatedPath, strlen($webrootPath));
}
$generatedUrl = str_replace('\\', '/', Yii::app()->urlManager->getBaseUrl().$generatedPath);
Thanks to both, guys!
Hwangar