We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17959 ☆ A M B ☆
    • 57 Posts
    Magnatron [Maarten Wolzak] Reply #1, 15 years, 11 months ago
    Would be so nice to have @FILE binding working from templates, snippets & chunks (not just TV’s)
    For now I’m adding the ’asset’ snippet at the start of a new evolution. (Didn’t have the time to migrate yet sad

    <?php
    if(!isset($src))return "Error: no src given...";
    $PS = strpos(MODX_BASE_PATH,"/") > -1 ? "/" : "\\";
    $asset = MODX_BASE_PATH.'assets'.$PS.$src;
    if(!file_exists($asset )) return "Error:Asset not found!<br><br>(".$asset.")";
    if(strrpos($asset ,".php")==strrpos($asset ,".")){
        $result = include( $asset );
    }else if(strrpos($asset ,".html")==strrpos($asset ,".")){
        $result = file_get_contents ( $asset );
    }
    return $result;
    ?>


    It will include (and therefor eval) .php files and will return all other types.
    Use like so:

    [[asset?src=`templates/mysite/base.tpl.html`]]
    


    Hope it’s useful

    NOTE: Can’t use this for PH chunks as PH’s will not be there yet in a snippet!