如何解决涉及Array到字符串转换问题的PrestaShop通知?

时间:2016-09-15 09:27:47

标签: php smarty prestashop prestashop-1.6

我正在尝试解决这些不断显示在我的日志中的注意事项:

PHP Notice:  Array to string conversion in /srv/myShop/shop/cache/smarty/compile/8e/46/82/8e468209001d92af523451f70674ce650370cb7c.file.header.tpl.php on line 99

以下是来自/8e468209001d92af523451f70674ce650370cb7c.file.header.tpl.php的片段,包括第99行(底线,评论):

<?php /* Smarty version Smarty-3.1.19, created on 2016-09-14 13:28:18
         compiled from "/srv/mySHop/shop/themes/simple-great/header.tpl" */ ?>
<?php /*%%SmartyHeaderCode:71159963757d93452f18b06-04565684%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '8e468209001d92af523451f70674ce650370cb7c' => 
    array (
      0 => '/srv/mySHop/shop/themes/simple-great/header.tpl',
      1 => 1444146241,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '71159963757d93452f18b06-04565684',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'lang_iso' => 0,
    'meta_title' => 0,
    'meta_description' => 0,
    'meta_keywords' => 0,
    'nobots' => 0,
    'nofollow' => 0,
    'favicon_url' => 0,
    'img_update_time' => 0,
    'css_files' => 0,
    'css_uri' => 0,
    'media' => 0,
    'js_defer' => 0,
    'js_files' => 0,
    'js_def' => 0,
    'js_uri' => 0,
    'HOOK_HEADER' => 0,
    'srpta' => 0,
    'page_name' => 0,
    'body_classes' => 0,
    'hide_left_column' => 0,
    'hide_right_column' => 0,
    'content_only' => 0,
    'restricted_country_mode' => 0,
    'geolocation_country' => 0,
    'base_dir' => 0,
    'shop_name' => 0,
    'HOOK_TOP' => 0,
    'left_column_size' => 0,
    'HOOK_LEFT_COLUMN' => 0,
    'right_column_size' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_57d934530ec1c9_43487918',
),false); /*/%%SmartyHeaderCode%%*/?>
//  SOME CODE HERE
//  .......
//  .......
//  .......
//  SOME CODE HERE  
<?php if (isset($_smarty_tpl->tpl_vars['css_files']->value)) {?>
        <?php  $_smarty_tpl->tpl_vars['media'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['media']->_loop = false;
     $_smarty_tpl->tpl_vars['css_uri'] = new Smarty_Variable;
     $_from = $_smarty_tpl->tpl_vars['css_files']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
    foreach ($_from as $_smarty_tpl->tpl_vars['media']->key => $_smarty_tpl->tpl_vars['media']->value) {
    $_smarty_tpl->tpl_vars['media']->_loop = true;
     $_smarty_tpl->tpl_vars['css_uri']->value = $_smarty_tpl->tpl_vars['media']->key;
    ?>   **//THIS IS LINE 99**
            <link rel="stylesheet" href="<?php echo $_smarty_tpl->tpl_vars['css_uri']->value;?>
    " type="text/css" media="<?php echo $_smarty_tpl->tpl_vars['media']->value;?>
    " />
        <?php } ?>

在这里你有主题/ simple-great / header.tpl:

<!DOCTYPE HTML>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 " lang="{$lang_iso}"><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie7" lang="{$lang_iso}"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9 ie8" lang="{$lang_iso}"><![endif]-->
<!--[if gt IE 8]> <html class="no-js ie9" lang="{$lang_iso}"><![endif]-->
<html lang="{$lang_iso}">
    <head>
        <meta charset="utf-8" />
        <title>{$meta_title|escape:'html':'UTF-8'}</title>
{if isset($meta_description) AND $meta_description}
        <meta name="description" content="{$meta_description|escape:'html':'UTF-8'}" />
{/if}
{if isset($meta_keywords) AND $meta_keywords}
        <meta name="keywords" content="{$meta_keywords|escape:'html':'UTF-8'}" />
{/if}
        <meta name="generator" content="PrestaShop" />
        <meta name="robots" content="{if isset($nobots)}no{/if}index,{if isset($nofollow) && $nofollow}no{/if}follow" />
        <meta name="viewport" content="width=device-width, minimum-scale=0.25, maximum-scale=1.6, initial-scale=1.0" /> 
        <meta name="apple-mobile-web-app-capable" content="yes" /> 
        <link rel="icon" type="image/vnd.microsoft.icon" href="{$favicon_url}?{$img_update_time}" />
        <link rel="shortcut icon" type="image/x-icon" href="{$favicon_url}?{$img_update_time}" />
{if isset($css_files)}
    {foreach from=$css_files key=css_uri item=media}
        <link rel="stylesheet" href="{$css_uri}" type="text/css" media="{$media}" />
    {/foreach}
{/if}
{if isset($js_defer) && !$js_defer && isset($js_files) && isset($js_def)}
    {$js_def}
    {foreach from=$js_files item=js_uri}
    <script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script>
    {/foreach}
{/if}
        {$HOOK_HEADER}



{if  $srpta.simgr_header_font  != 'Trebuchet MS'  } 
<link href='https://fonts.googleapis.com/css?family={$srpta.simgr_header_font}:{configuration::get("simgr_header_font_weight")}&subset={configuration::get("simgr_header_font_subset")}' rel='stylesheet' type='text/css'>
{/if}

{if  $srpta.simgr_shop_body_font != 'Trebuchet MS'  }   

<link href='https://fonts.googleapis.com/css?family={$srpta.simgr_shop_body_font}:{configuration::get("simgr_shop_body_font_weight")}&subset={configuration::get("simgr_shop_body_font_subset")}' rel='stylesheet' type='text/css'>
{/if}
        <!--[if IE 8]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
         {$srpta.simgr_tracking_code}
    </head>

    <body{if isset($page_name)} id="{$page_name|escape:'html':'UTF-8'}"{/if} class="{if isset($page_name)}{$page_name|escape:'html':'UTF-8'}{/if}{if isset($body_classes) && $body_classes|@count} {implode value=$body_classes separator=' '}{/if}{if $hide_left_column} left-column-hidden{/if}{if $hide_right_column} right-column-hidden{/if} {if !$hide_right_column && !$hide_left_column} show_both_column {/if}{if $content_only} content_only{/if} lang_{$lang_iso}">
     <input type="hidden" value="{$srpta.simgr_carousel_click_limit}" name="show-more-count-val" id="show-more-count-val">
    <input type="hidden" value="{$srpta.simgr_revolution_width_set}" name="simgr_revolution_width_seth" id="simgr_revolution_width_seth">
    {if !$content_only}
        {if isset($restricted_country_mode) && $restricted_country_mode}
            <div id="restricted-country">
                <p>{l s='You cannot place a new order from your country.'} <span class="bold">{$geolocation_country}</span></p>
            </div>
        {/if}
        <div id="page">
            <div class="header-container">
                <header id="header">
                    <div class="banner">
                        <div class="container">
                            <div class="row">
                                {hook h="displayBanner"}
                            </div>
                        </div>
                    </div>
                    <div class="nav">
                        <div class="container">
                            <div class="row">
                                <nav>
                                    <div class="col-md-9 col-sm-11 col-xs-12 nav_block_top clearfix">{hook h="displayNav"}</nav>
                            </div>
                        </div>
                    </div>
                    <div class="header-container">
                        <div class="container">
                            <div class="row">
                                <div id="header_logo">
                                    <a href="{$base_dir}" title="{$shop_name|escape:'html':'UTF-8'}">
                                        <img class="logo img-responsive" src="{$srpta.simgr_sitelogo}" alt="{$shop_name|escape:'html':'UTF-8'}"/>
                                    </a>
                                <!-- its div cloase in smarttopnav -->
                                {if isset($HOOK_TOP)}{$HOOK_TOP}{/if}
                            </div>
                        </div>
                    </div>
                </header>
            </div>
            <div class="columns-container">
                <div id="columns" class="container">

                    <div class="row">
                        <div id="top_column" class="center_column ">{hook h="displayTopColumn"}</div>
                    </div>
                    <div class="row">
                        {if $page_name !='index'}
                            <div class="container_inner_other_page col-md-12">
                        {/if}

                        {if isset($left_column_size) && !empty($left_column_size)}
                              {if $page_name !='index' && $page_name !='pagenotfound'}
                            {include file="$tpl_dir./breadcrumb.tpl"}
                        {/if}
                            <div id="left_column" class="column col-xs-12 col-sm-{$left_column_size|intval} main-sidebar sidebar">
                                {$HOOK_LEFT_COLUMN}
                            </div>
                            {/if}
                            <div id="center_column" class="center_column col-xs-12 col-sm-{12 - $left_column_size - $right_column_size}">


        {/if}

1 个答案:

答案 0 :(得分:0)

打开/themes/simple-great/header.tpl文件

尝试替换

{foreach from=$css_files key=css_uri item=media}
<link rel="stylesheet" href="{$css_uri}" type="text/css" media="{$media}" />
{/foreach}

{foreach $css_files as $css_uri => $media}
<link rel="stylesheet" href="{$css_uri}" type="text/css" media="{$media}" />   
{/foreach}

如果它没有用,那么你可以尝试打印$ css_files变量,它可能是一个字符串,你正在使用foreach循环。