2016-12-04 54 views
0

Lithium的新手。锂离子内联SVG查看

我试图在锂视图中内联一个SVG文件。

在以前的PHP框架我只想做到以下几点:

<?php echo file_get_contents('images/styleguide/left-arrow.svg'); ?> 

锂这将抛出一个漂亮的史诗误差与问候到它要找的文件:

警告:的file_get_contents (images/styleguide/left-arrow.svg):失败 打开流: //app/resources/tmp/cache/templates/template_styleguide_index.html_17440333_1480885998_1509.php没有这样的文件或目录

由于这个位置,我想知道做这个的“锂方式”是什么(如果有的话)。

回答

1

我找到了解决方案(如果有更好的解决方案,请添加答案)。

使用介质类来获取root或您的静态文件:

use lithium\net\http\Media; 

$webrootPath = Media::webroot(true); 

使用这个你可以得到该文件的内容:

$watchRound = file_get_contents($webrootPath.'/images/styleguide/watch-round.svg'); 

随即开始吧:

<button class="toolbar__btn js-styleguide-viewport-watch-round"> 
    <?php echo $watchRound; ?> 
</button>