Prestashop 1.7如何编辑$stylesheets smarty变量

Prestashop 1.7如何编辑$stylesheets smarty变量,prestashop,prestashop-1.7,Prestashop,Prestashop 1.7,我正在努力提高我的谷歌页面速度。在“预加载密钥请求”类别中,我可以看到这样的结果: …css/199038f….woff2 4500 ms …css/19c1b86….woff2 4230 ms …css/570eb83….woff2 4080 ms 这些文件位于classic/assets/css/中,无论如何,我找不到它添加到代码中的位置,因此我可以修复这些链接以进行预加载。我在classic/templates/_partials/中找到了一个文件stylesheets.tpl,我已更改

我正在努力提高我的谷歌页面速度。在“预加载密钥请求”类别中,我可以看到这样的结果:

…css/199038f….woff2
4500 ms
…css/19c1b86….woff2
4230 ms
…css/570eb83….woff2
4080 ms
这些文件位于classic/assets/css/中,无论如何,我找不到它添加到代码中的位置,因此我可以修复这些链接以进行预加载。我在classic/templates/_partials/中找到了一个文件stylesheets.tpl,我已更改:

{foreach $stylesheets.external as $stylesheet}
  <link rel="stylesheet" href="{$stylesheet.uri}" type="text/css" media="{$stylesheet.media}">
{/foreach}
{foreach$stylesheets.external as$stylesheet}
{/foreach}

{foreach$stylesheets.external as$stylesheet}
{/foreach}
它为洞察工作,没有更多关于它的警告,但不幸的是它破坏了网站(表现得好像根本没有风格)。我尝试了更多的组合,如:as=“font”,as=“font”type=“woff2”,但没有效果

我现在的计划是从$stylesheets.external中删除这三个css文件,然后手动将它们添加到head.tpl中,但我找不到在哪里可以找到这个对象


如何编辑$stylesheets变量?

您可以找到在FrontController.php中分配的stylesheets变量

函数名显示()


文件路径:classes/controller/FrontController.php

确实,FrontController中提到的函数包含:

public function display()
    {
        $this->context->smarty->assign(array(
            'layout' => $this->getLayout(),
            'stylesheets' => $this->getStylesheets(),
            'javascript' => $this->getJavascript(),
            'js_custom_vars' => Media::getJsDef(),
            'notifications' => $this->prepareNotifications(),
        ));

        $this->smartyOutputContent($this->template);

        return true;
    }
所以我搜索了这个getStylesheets(),就是这样:

    public function getStylesheets()
    {
        $cssFileList = $this->stylesheetManager->getList();

        if (Configuration::get('PS_CSS_THEME_CACHE')) {
            $cssFileList = $this->cccReducer->reduceCss($cssFileList);
        }

        return $cssFileList;
    }

然后搜索stylesheetManager等,但无论如何,它不是将某些样式表添加到此变量的位置(也不是在stylesheetManager.php中)。我需要找到一个文件(大约),其中所有这些样式表都被注册/添加到这个样式表变量中。有人知道它在哪里吗?

我已经解释过,如何修改显示函数并在样式表中分配新数组。请检查以下内容:

public function display()
            {

            $arrStylessheets =  $this->getStylesheets();

            print_r($arrStylessheets);//check those stylesheets keys here

            unset($arrStylessheets['<those stylesheets here>']);
          
           
            $this->context->smarty->assign(array(
                'layout' => $this->getLayout(),
                'stylesheets' => $arrStylessheets,// pass new array stylesheet  
                'javascript' => $this->getJavascript(),
                'js_custom_vars' => Media::getJsDef(),
                'notifications' => $this->prepareNotifications(),
            ));
    
            $this->smartyOutputContent($this->template);
    
            return true;
        }
公共功能显示()
{
$arrStylessheets=$this->getStylesheets();
打印($arrStylessheets);//在此处检查这些样式表键
未结算($arrStylessheets['');
$this->context->smarty->assign(数组)(
'layout'=>this->getLayout(),
'stylesheets'=>$arrStylessheets,//传递新数组样式表
'javascript'=>this->getJavascript(),
'js_custom_vars'=>Media::getJsDef(),
“通知”=>$this->prepareNotifications(),
));
$this->smartyOutputContent($this->template);
返回true;
}
public function display()
            {

            $arrStylessheets =  $this->getStylesheets();

            print_r($arrStylessheets);//check those stylesheets keys here

            unset($arrStylessheets['<those stylesheets here>']);
          
           
            $this->context->smarty->assign(array(
                'layout' => $this->getLayout(),
                'stylesheets' => $arrStylessheets,// pass new array stylesheet  
                'javascript' => $this->getJavascript(),
                'js_custom_vars' => Media::getJsDef(),
                'notifications' => $this->prepareNotifications(),
            ));
    
            $this->smartyOutputContent($this->template);
    
            return true;
        }