Page 1 of 1

assets_url is giving me an error

Posted: Tue Jan 30, 2018 10:57 am
by Simon66
I checked the 'config.php Reference' and it said there was a default value ($config['root_url'].'/assets') for assets_url.

I'm using cmsms 2.2.5

But when I use {assets_url} in my template it gives an error.

I have also tried with/without setting it in config.php and it gives an error both times.

Has anyone else experienced this?

Re: assets_url is giving me an error

Posted: Tue Jan 30, 2018 1:18 pm
by PinkElephant
I guess the online reference is currently out of whack but it might be the code: 2.2.5 lib/classes/class.cms_config.php suggests that assets_dir and assets_path are the only two 'assets' values that are read.

Re: assets_url is giving me an error

Posted: Tue Jan 30, 2018 1:43 pm
by Rolf
There isn't a {assets_url} tag yet... The config setting is for core to know where the plugins (etc) folder is.

Re: assets_url is giving me an error

Posted: Tue Jan 30, 2018 9:18 pm
by Simon66
Thanks for the info.

Re: assets_url is giving me an error

Posted: Wed Jan 31, 2018 2:56 am
by aviapic
To get {assets_url}

just create a plugin in a new php file

name the file : 'function.assets_url.php'

Code: Select all

<?php
function smarty_function_assets_url($params, &$smarty)
{
$config = CmsApp::get_instance()->GetConfig();

$out = $config['assets_url'] ? $config['assets_url'] : false;

if( ! $out )
    {
        /* get assets_dir  */
        $asset_dir = str_replace($config['root_path'],'',$config['assets_path']);

        /* cleanup for localhost */
        $asset_dir = str_replace('\\','/',$asset_dir);

        $out = $config->smart_root_url().$asset_dir;
    }

    if( isset($params['assign']) )
    {
        $smarty->assign(trim($params['assign']),$out);
        return;
    }

    return $out;
}
?>
put this file in directory : assets/plugins/

then you can use {assets_url} in your template