CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#6960] Add a param to function_global_content to not display an error if the requested GCB doesn't exist

avatar
Created By: Jocelyn Lusseau (kraygoon)
Date Submitted: Sun Oct 16 11:40:12 -0400 2011

Assigned To:
Version: 1.9.4.3
CMSMS Version: 1.9.4.3
Severity: Trivial
Resolution: Won't Fix
State: Closed
Summary:
Add a param to function_global_content to not display an error if the requested GCB doesn't exist
Detailed Description:
Is it possible to add a param like display_error="false/true" (default:true) to
hide an error if the requested GCB doesn't exist ?

If a template use a GCB that was renamed it could be interesting to hide the
error instead of displying it.

The solution is here :

The call :
{global_content name="my_block_that_does_not_exist" display_error="false"}

The modification of function.global_content.php :

function smarty_cms_function_global_content($params, &$smarty)
{
  $smarty->assign('gcb_params',$params);
	$gcb_name = 'globalcontent:'.$params['name'] ;
	$txt = $smarty->fetch($gcb_name);
	
if ($params['display_error'] AND $params['display_error'] == "false" AND
!$smarty->template_exists($gcb_name))
	{
		$txt = "";
	}
  if( isset($params['assign']) )
    {
      $smarty->assign(trim($params['assign']),$txt);
      return;
    }
  return $txt;
}


History

Comments
avatar
Date: 2011-10-29 16:27
Posted By: Robert Campbell (calguy1000)

it is not a bug that the system reports an error when you call something that
does not exist.
      
Updates

Updated: 2012-04-01 14:42
state: Open => Closed

Updated: 2011-10-29 16:26
resolution_id: => 8