Prestashop 根目录 [英] Prestashop root directory

查看:46
本文介绍了Prestashop 根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 prestashop,在主题中我添加了自己的目录,其中包含一个样式表

I am working with prestashop and in the theme I have added my own directory with a stylesheet inside it

然后我在 header.tpl 中链接了样式表例如

I have then linked the stylesheet in header.tpl eg

<link rel="stylesheet" type="text/css" href="/directory/style.css" />

但是,如果我将 prestashop 安装在子目录中,例如

however If i install prestashop in a subdirectory eg

www.website.com/prestashop/那么样式没有显示,因为它认为站点的根是 www.website.com.是否有我可以用来回显安装 prestashop 的目录的 pretsashop 字符串?

www.website.com/prestashop/ then the style is not showing because it thinks the root of the site is www.website.com. is there a pretsashop string I can use to echo the directory prestashop is installed in?

例如类似的东西

$ps_dir 或$ps_uri ???

$ps_dir or $ps_uri ???

所以我可以做这样的事情

So I can do something like this

<link rel="stylesheet" type="text/css" href="{$ps_dir}/directory/style.css" />

干杯

推荐答案

假设您使用的是 PS 1.4 以后的版本,那么您确实应该始终将其他样式表加入队列,尽管要做到这一点,您需要向FrontController 类或创建特定于主题的模块.这样做的好处是 Prestashop 会将您的 CSS(或 javascript)包含到它的最小化和 CDN 代码中,这可以显着加快您的网站速度.

Assuming you're using PS 1.4 onwards, then you should really always enqueue additional stylesheets, although to do that you would need to either add a simple override to the FrontController class or create a theme-specific module. The advantage of this is that Prestashop will include your CSS (or javascript) into it's minimisation and CDN code, which can speed up your site considerably.

有什么理由需要一个单独的 css 文件,并且不能为主题 global.css 命名您需要的 css 吗?使用 global.css 文件意味着它将被自动包含和最小化.

Is there any reason why you need to have a separate css file, and can't name the css you need for your theme global.css? Using the global.css file means that it will get included and minimised automatically.

如果您可能需要有条件地添加 css(您必须将其硬编码到主题中)或引用其他主题资源,那么您还可以使用以下变量:

If you perhaps need to add css conditionally (which is where you will have to hard-code it into the theme) or refer to other theme resources then you can also use the following variables:

{$css_dir} The /css directory in your theme
{$js_dir}  The /js directory in yout theme
{$img_dir} /img directory in your theme
{$tpl_dir} Your theme's top-level directory 

这篇关于Prestashop 根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆