Shopsite INCLUDE for CSS Needs <style> Opener?

General ShopSite user discussion

Shopsite INCLUDE for CSS Needs <style> Opener?

Postby jontaco » Thu May 12, 2011 12:37 pm

I have created a Shopsite INCLUDE for my CSS styles, just the way that Shopsite has instructed me.

The INCLUDE points to an external file in the shopsite-data/templates/includes directory.

However, I have discovered that I am still required to surround my styles with a closer and opener, even though it is external:

<style type="text/css">
CSS goes here
</style>


Doesn't this defeat the whole purpose of creating an external stylesheet? Shouldn't the Style opener and closer only be necessary for styles created in the header?

Thanks
jontaco
 
Posts: 39
Joined: Sun Apr 20, 2008 8:05 pm
Location: Huntsville, AL

Re: Shopsite INCLUDE for CSS Needs <style> Opener?

Postby Jim » Thu May 12, 2011 1:40 pm

The files in the shopsite-data/templates/includes directory will actually be added to the html of the page and not as an external reference. (the shopsite-data/templates/includes directory is in a password protected area so it can't be view from the web)

If you want to have external references you need to put the file in your store's output directory where the .html file are located.
ShopSite 10sp2 added a template area called "Publish files" under Merchandising > Custom Templates > Includes. Files put in this location will be "published" to a publish directory under your store's output directory. You can then use the external reference to those files in your templates.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Shopsite INCLUDE for CSS Needs <style> Opener?

Postby Kennedy » Fri Jun 10, 2011 6:26 am

I believe what jontaco was referring to is that when you do it the way shopsite wants it done, it puts your entire css file contents into the source of your pages. I want my style sheets to remain where they are, safely stored on my server not available to anyone who views my page source.
Kennedy
 
Posts: 33
Joined: Fri Jun 10, 2011 6:18 am

Re: Shopsite INCLUDE for CSS Needs <style> Opener?

Postby BFChris » Fri Jun 10, 2011 7:36 am

Yes, the way Shopsite does it puts the entire content of the CSS styles on the page.

Jim's workaround resolves that issue and includes the CSS in an external file as is more "common."

Of course, even in an external stylesheet, a smart web surfer can still see the full contents of your CSS file. The more practical reason to use an external stylesheet is that it keeps common material in one place. Hence a web browser can cache it and not have to reload the information for every page visited. This makes pages smaller and faster to load.
~~Barefoot Chris
--------------------------------
Barefoot Chris Web Design
www.barefootchris.net
--------------------------------
BFChris
 
Posts: 322
Joined: Mon Oct 09, 2006 3:28 pm
Location: PA

Re: Shopsite INCLUDE for CSS Needs <style> Opener?

Postby Jim » Fri Jun 10, 2011 7:59 am

A "publish" files directory was added to the templates area of ShopSite in version 10 sp1 and it allows using an html <link ...> type access to css and javascript files. Prior to that version it was only possible to included the css, which contained ShopSite template tags, in the template directly or the template tags would not be evaluated. If your css did not include ShopSite template tags you could also have manually placed a css file in your store's output directory and used the html <link ..> to reference it. With the addition of the "publish" template file it is now possible to inlcude ShopSite template tags in the css and still be able to reference the file through the html <link ...>. To do this add the css file to the Merchandising > Custom Templates > Includes >Publish area. Then when the store is published the file will be evaluated for ShopSite template tags and a copy will be placed in the store's output directory, in a folder called "publish". You can then link to the file in your html/template instead of having the code actually included in the page source. The link would be something like <link type="text/css" rel="stylesheet" href="http://mydomain.com/publish/flex-build.css">
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Shopsite INCLUDE for CSS Needs <style> Opener?

Postby Kennedy » Fri Jun 10, 2011 8:54 am

Thank you much Jim, that was exactly what I was looking for.
Kennedy
 
Posts: 33
Joined: Fri Jun 10, 2011 6:18 am


Return to User Forum

Who is online

Users browsing this forum: No registered users and 72 guests