1

您好我正在尝试使用刀片为我的网站创建动态跟踪代码。这是我到目前为止所做的,我尝试直接屈服于 piwikTracker var,但是由于 var 似乎正在工作,所以传递了各种错误,但我现在没有在后端获得任何统计信息

 <!-- Piwik --> 
<script type="text/javascript">
var track =  @yield('track');
var pkBaseURL = (("https:" == document.location.protocol) ? "https://centralcoastwindowcleaners.com.au/track/" : "http://centralcoastwindowcleaners.com.au/track/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", track);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://centralcoastwindowcleaners.com.au/track/piwik.php?         idsite=@yield('track')" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

有没有办法我可以逃脱它并做类似的事情:

<!-- Piwik --> 
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://centralcoastwindowcleaners.com.au/track/" : "http://centralcoastwindowcleaners.com.au/track/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", @yield('track'));
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://centralcoastwindowcleaners.com.au/track/piwik.php?         idsite=@yield('track')" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
4

1 回答 1

0

在您展示的上下文中,您不需要产生一个部分,只需要一个变量或字符串。这样你就可以通过了

var track =  {{$track}};

部分对于嵌套视图和部分视图很有帮助,但对于单个变量来说过大(以及未设计)。如果由于某种原因您无法存储和传递 $track,则将整行与 yield 而不仅仅是变量一起传递。

//var track = 'varYouArePassing';
@yield('track'); 
于 2012-12-27T23:20:28.537 回答