简体   繁体   English

在sitecore中,我可以在哪里添加自己的自定义CSS?

[英]In sitecore, where can I add my own custom CSS?

Our sitecore developer quit suddenly and I need to make a small change. 我们的sitecore开发人员突然退出,我需要进行一些小的更改。 I'm a front end developer and have no real experience with the sitecore backend. 我是前端开发人员,对sitecore后端没有任何实际经验。 I just need to add some CSS styles to the main style.css file or I need to add my own file. 我只需要在main.css文件中添加一些CSS样式,或者需要添加自己的文件。 I've got full access to the CMS, but no access to the hosting account. 我拥有对CMS的完全访问权限,但无权访问托管帐户。 I'm trying to find the main CSS file through the CMS browser, but I'm not having any luck. 我正在尝试通过CMS浏览器找到主要的CSS文件,但是我没有任何运气。

Can you help me either: A) Locate the main CSS file so I can add some classes (preferred) B) Add my own link in the tag to my own CSS file hosted on another domain C) Use the home page link to CSS file where I can add some classes 您能帮我一个忙吗?A)找到主CSS文件,以便我可以添加一些类(首选)B)将标记中的我自己的链接添加到另一个域中托管的我自己的CSS文件中C)使用首页链接到CSS文件我可以在其中添加一些课程

A note about OPTION C... I'm in the CMS and I see there is a system folder and in that a CSS folder where I can add a custom.css file. 关于选项C的注释...我在CMS中,看到一个系统文件夹,在那个CSS文件夹中可以添加custom.css文件。 Then I go to the home page and I can actually call that CSS file from a field in the home page BUT, when the site loads, even though it's calling this file, it comes over as .aspx and it's blank so no styles I set are applied. 然后我转到主页,我实际上可以从主页中的某个字段调用该CSS文件,但是当网站加载时,即使它正在调用此文件,它也会以.aspx形式出现,并且为空,因此我没有设置样式被应用。

you can find the location of file as suggested by Maciej or use firebug or any other developer tools to find the location of main style.css. 您可以按照Maciej的建议找到文件的位置,也可以使用firebug或任何其他开发人员工具找到main style.css的位置。 Once you get the location you can browser the physical file on server by going to Sitecore start menu -> All Application ->File explorer . 找到位置后,您可以转到Sitecore开始菜单->所有应用程序->文件资源管理器来浏览服务器上的物理文件。 Download file using File explorer make your changes and upload it back, make sure you check override existing file when you upload. 使用文件资源管理器下载文件进行更改并将其上传回,请确保在上传时选中覆盖现有文件。 Also make sure you upload file to delivery server once you test your changes, typically you will be accessing Sitecore using Authoring Server so instance you are accessing might not be same as CD server. 此外,还要确保在测试更改后将文件上传到交付服务器,通常情况下,您将使用Authoring Server访问Sitecore,因此您要访问的实例可能与CD服务器不同。

You could right-click in your browser to figure out where your css is coming from relative to the server root. 您可以在浏览器中单击鼠标右键,以找出css来自相对于服务器根目录的位置。 Although not completely fool-proof, this method may give you a quick answer. 尽管这种方法并不十分简单,但是可以快速给出答案。

According to documentation for sitecore 6.2, style sheet location is determined by the developer so it could be anywhere that the developer has chosen. 根据sitecore 6.2的文档,样式表的位置由开发人员确定,因此它可以位于开发人员选择的任何位置。

Take a look at this answer for more details. 请查看此答案以获取更多详细信息。

You should also be wary of how code gets built and deployed. 您还应该警惕代码的构建和部署方式。 Most Sitecore developers have very specific methodologies for how they include code (including front end) in their solutions. 大多数Sitecore开发人员对于如何在解决方案中包括代码(包括前端)都有非常具体的方法。

Make sure you're aware of any deployment methodologies your developer used, so that your work doesn't get overwritten in a future deployment. 确保您了解开发人员使用的任何部署方法,以免您的工作在以后的部署中被覆盖。

Did they use a source control management solution (like Git or TFS)? 他们是否使用了源代码管理管理解决方案(如Git或TFS)? Did they use an automated tool to do deployments (like Octopus Deploy)? 他们是否使用自动化工具进行部署(例如Octopus Deploy)?

If you can find main CSS file in physical location, you can update the file with new CSS styles. 如果可以在实际位置找到主CSS文件,则可以使用新的CSS样式更新文件。

If you want to add your own CSS as an additional CSS style, you might need to create a new template for css link and use that template when you create new page with your own CSS. 如果要添加自己的CSS作为其他CSS样式,则可能需要为css链接创建一个新模板,并在使用自己的CSS创建新页面时使用该模板。

Just for future reference, by default the location of the used css files is described in Sitecore.config like this: 仅供以后参考,默认情况下,Sitecore.config中描述了所用css文件的位置,如下所示:

    <!--  WEB SITE STYLESHEET
        CSS file for HTML content of Sitecore database.
        The file pointed to by WebStylesheet setting is automatically included in Html and Rich Text fields.
        By using it, you can make the content of HTML fields look the same as the actual Web Site
  -->
<setting name="WebStylesheet" value="/default.css"/>

Paths are relative to the root of your sitecore installation, you can find default.css in the root of the sitecore application on the webserver. 路径是相对于sitecore安装目录的根目录的,您可以在Web服务器上sitecore应用程序的根目录中找到default.css。

在Chrome浏览器中,检查元素并选择“源”选项卡,然后打开所需的CSS文件并进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM