2012-05-10 33 views
0

我使用Symfony2.0MopaBootstrapBundle v2.x_sf2.0,它們提供Twitter-bootstrap。實際上,我包含了像documentation那樣的Less文件。該文件包含來自Twitter-bootstrap的所有Less文件。我的問題是我無法訪問其他文件中TwitterBootstrap提供的mixins。如何重用Twitter-bootstrap使用MopaBootstrapBundle提供的變量?

{% stylesheets filter='less 
     '@MopaBootstrapBundle/Resources/public/less/mopabootstrapbundle.less' 
     '@MyBundle/Resources/public/less/myfile.less' 
    %} 
    <link href="{{ asset_url }}" type="text/css" rel="stylesheet" /> 
    {% endstylesheets %} 

這是解決這一問題的最佳方法是什麼?

在此先感謝。

回答

1

獲取捆綁包中的mixin和變量的一種方法是將mopabootstrap.less文件複製到@MyBundle/Resources/public/less/bootstrap.less,並修改導入的路徑以指向MopabootstrapBundle。我還會添加一個名爲@import "bootstrap-override.less";的附加最後一個導入,用於添加其他元素的樣式。然後

你的樣式塊將如下所示:

{% stylesheets filter='less 
    '@MyBundle/Resources/public/less/bootstrap.less' 
%} 
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" /> 
{% endstylesheets %} 

在你需要改變的核心引導文件中的一個(你可能需要variables.less)的情況下,把它們複製到你的項目和變更bootstrap.less中的導入路徑。

+0

我嘗試用你的解決方案來管理這個問題,但我還沒有成功導入文件。 我使用這個URL @import「/vendor/bundles/Mopa/BootstrapBundle/Resources/public/less/mopabootstrapbundle.less」;從MopaBootstrapBundle導入所有文件,並且從服務器沒有錯誤,所以我認爲路徑是正確的。 你知道什麼是錯的嗎? 謝謝 – gperriard

+0

你已經給它提供了less文件的絕對路徑,記住在到達瀏覽器之前編譯的文件越少,所以你應該把它改成相對路徑'@import'../../../。 /../../../vendor/bundles/Mopa/BootstrapBundle/Resources/public/less/mopabootstrapbundle. less''。沒有測試,但應該工作。 – cvaldemar

+0

我得到了500錯誤。我嘗試使用../../../../../../vendor/bundles/Mopa/BootstrapBundle/Resources/public/less/m opabootstrapbundle from/src/Btask/DashboardBundle/Resources/public/less/main.less – gperriard

相關問題