How to load assets from modules to view in asgardcms

  • Hello greeting..

    I am using asgardCMS and I have created module name : Employee and added asset files(css,js and images) in module asset folder. and i am using my custom front-end theme name : Testtheme.

    now i want to use that asset files from module to my custom theme view file(front-end side). I have followed many solution from internet but still not got success.

    => I have added asset file in Modules => Employee(module_name) => Assert (folder) => css, js and images file

    => after that i have fire command for publish that : php artisan module:publish employee

    => i am not sure how to load that asset in my custom theme view file.

    Anybody can help me for same ?


  • Global Moderator


    After you have published your module assets you can access them by loading them:

    • If you want to include them straight from withing theme you can do {!! Module::asset('employee:js/fancy-min.js'); !!}
    • If you want to load from php (controller/composers etc.) use AssetManager and then require withAssetPipeline. And then pass them to your view.

  • Thanks @armababy

    Working fine with theme view file but load using controller is not working.

    Can you please explain bit more about load from controller. it is not working.


  • Global Moderator


    What kind of Asgard version are you using?

  • Hello,

    I am working on latest version of Asgard CMS(platform=2.0.*).


  • Global Moderator

    For the backend controllers you can extend AdminBaseController.
    For the frontend ones you have to replicate same stuff (in your constructors resolve AssetManager and AssetPipeline).

    And then use appropriate functions to work with assets AssetManager documentation

Log in to reply

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.