Snippets - how to specifiy CSS/styles
Snippets - how to specifiy CSS/styles
I have formatted text in a topic that I want to convert to a snippet. If I do Format > Create Snippet, it duly creates the snippet in the Resources folder and, if I accept the default, replaces the source content with the new snippet.
However, when I want to edit the snippet, the choice of styles is very limited. I can't see where they're coming from (nothing relevant in Properties), let alone work out how to attach the right CSS and thus select the styles I want.
Furthermore, I don't understand why it still looks OK in destination topics, using styles that aren't visible in the snippet itself or in the Style list when editing the snippet.
What's going on, and what's the best approach?
Thanks.
However, when I want to edit the snippet, the choice of styles is very limited. I can't see where they're coming from (nothing relevant in Properties), let alone work out how to attach the right CSS and thus select the styles I want.
Furthermore, I don't understand why it still looks OK in destination topics, using styles that aren't visible in the snippet itself or in the Style list when editing the snippet.
What's going on, and what's the best approach?
Thanks.
"Books are a narcotic." (Franz Kafka)
I wonder what he'd say about help files?
I wonder what he'd say about help files?
Re: Snippets - how to specifiy CSS/styles
No idea if this is the right way to do it, but what I have done is opened the snipped with the Internal Text Editor and added:
<link href="../Stylesheets/MyCSS.css" rel="stylesheet" type="text/css" />
to the file after the <head> line.
You can open any topic to get the correct name and path of your CSS, then copy and paste into the snippet.
Once you do this, your snippet will show the available styles from the CSS.
<link href="../Stylesheets/MyCSS.css" rel="stylesheet" type="text/css" />
to the file after the <head> line.
You can open any topic to get the correct name and path of your CSS, then copy and paste into the snippet.
Once you do this, your snippet will show the available styles from the CSS.
-
KevinDAmery
- Propellus Maximus
- Posts: 1985
- Joined: Tue Jan 23, 2007 8:18 am
- Location: Darn, I knew I was around here somewhere...
Re: Snippets - how to specifiy CSS/styles
They're just the basic bob HTML styles. It is possible to tell the snippet to reference an specific CSS file which will make those styles available in the style window; however, it is not necessary for the snippet to work correctly (see below).Cecily wrote:However, when I want to edit the snippet, the choice of styles is very limited. I can't see where they're coming from (nothing relevant in Properties), let alone work out how to attach the right CSS and thus select the styles I want.
The HTML in the snippet gets referenced into the topic as if it was part of the topic code. This means that any styles in the snippet get interpreted using the same CSS that the topic is using, so the appearance remains consistent.Furthermore, I don't understand why it still looks OK in destination topics, using styles that aren't visible in the snippet itself or in the Style list when editing the snippet.
What's going on, and what's the best approach?
Thanks.
Until next time....

Kevin Amery
Certified MAD for Flare
Kevin Amery
Certified MAD for Flare
Re: Snippets - how to specifiy CSS/styles
That's one way, and another way is to go to Tools > Stylesheet Links. That should enable you to link your stylesheet of choice to the snippet.Valiant wrote:No idea if this is the right way to do it, but what I have done is opened the snipped with the Internal Text Editor and added:
<link href="../Stylesheets/MyCSS.css" rel="stylesheet" type="text/css" />
to the file after the <head> line.
You can open any topic to get the correct name and path of your CSS, then copy and paste into the snippet.
Once you do this, your snippet will show the available styles from the CSS.
Flare v6.1 | Capture 4.0.0
-
doc_guy
- Propellus Maximus
- Posts: 1979
- Joined: Tue Nov 28, 2006 11:18 am
- Location: Crossroads of the West
- Contact:
Re: Snippets - how to specifiy CSS/styles
Also, I believe that if you link a style sheet to the project then snippets in the project will show those styles.
-
Andrew Heard
- Sr. Propeller Head
- Posts: 139
- Joined: Tue Aug 19, 2008 12:17 am
- Location: Perth, Western Australia
Re: Snippets - how to specifiy CSS/styles
It's true that snippets are formatted according to the host topic's stylesheet. This is a really really good feature.
However, Analyzer doesn't know this. Analyzer topic: Help? Analyzer finding "broken" links, etc., in Snippets
So I added the <link href="../Stylesheets... line to the 20 or so snippets that I have so that they don't bring up "undefined class" errors in Analyzer.
However, Analyzer doesn't know this. Analyzer topic: Help? Analyzer finding "broken" links, etc., in Snippets
So I added the <link href="../Stylesheets... line to the 20 or so snippets that I have so that they don't bring up "undefined class" errors in Analyzer.
Andrew - I don't see how Tools > Stylesheet Links assigns a stylesheet to a snippet. Could you explain please?Andrew wrote:... another way is to go to Tools > Stylesheet Links. That should enable you to link your stylesheet of choice to the snippet.
Some mornings it just doesn't seem worth it to gnaw through the leather straps.
Re: Snippets - how to specifiy CSS/styles
Thanks, but that had no effect.Valiant wrote:opened the snipped with the Internal Text Editor and added:
<link href="../Stylesheets/MyCSS.css" rel="stylesheet" type="text/css" />
to the file after the <head> line.
However, it turned out that although all my topics pick up the correct stylesheet when I create them, I hadn't defined a master stylesheet for the project. (Thanks Doc Guy.)
I went to Project > Project Properties > Master Stylesheet and selected the CSS, after which all my snippets picked up the stylesheet, so I can now apply Note and other styles.
"Books are a narcotic." (Franz Kafka)
I wonder what he'd say about help files?
I wonder what he'd say about help files?
-
Andrew Heard
- Sr. Propeller Head
- Posts: 139
- Joined: Tue Aug 19, 2008 12:17 am
- Location: Perth, Western Australia
Re: Snippets - how to specifiy CSS/styles
As I understand it, a master stylesheet is OK if you only have one css, but no good if you have more. I have two, so couldn't apply a master stylesheet to the project.
At the risk of appearing rude, you did change the file path in the <link href="../Stylesheets... line, and not just paste it in verbatim, didn't you? (Making sure you have the right number of "../"s to get to the root folder for your stylesheets.)
At the risk of appearing rude, you did change the file path in the <link href="../Stylesheets... line, and not just paste it in verbatim, didn't you? (Making sure you have the right number of "../"s to get to the root folder for your stylesheets.)
Some mornings it just doesn't seem worth it to gnaw through the leather straps.
Re: Snippets - how to specifiy CSS/styles
Presumably you could still apply a master stylesheet, but you'd have to override it for individual topics.Andrew Heard wrote:As I understand it, a master stylesheet is OK if you only have one css, but no good if you have more. I have two, so couldn't apply a master stylesheet to the project.
It's not rude to query something when you're trying to help.Andrew Heard wrote:At the risk of appearing rude, you did change the file path in the <link href="../Stylesheets... line, and not just paste it in verbatim, didn't you?
I'm not sure what you're saying I should have changed. I didn't paste the example from this forum, but I did paste from one topic to the snippet because it didn't look as if there was any difference in paths etc.
"Books are a narcotic." (Franz Kafka)
I wonder what he'd say about help files?
I wonder what he'd say about help files?
-
Andrew Heard
- Sr. Propeller Head
- Posts: 139
- Joined: Tue Aug 19, 2008 12:17 am
- Location: Perth, Western Australia
Re: Snippets - how to specifiy CSS/styles
If you have a master stylesheet you can't override the stylesheet for individual topics.
Stylesheet not being applied
Stylesheet not available
The path to the stylesheet could of course be an absolute path. In the <head> area it's coded as a relative path. All I'm suggesting is that you check that the relative path is correct.
If your snippet is in Content > Resources > Snippets,
And your stylesheet is in Content > Resources > Stylesheets, then your code should read "../Stylesheets/<whatever your stylesheet name is>"
Stylesheet not being applied
Stylesheet not available
The path to the stylesheet could of course be an absolute path. In the <head> area it's coded as a relative path. All I'm suggesting is that you check that the relative path is correct.
If your snippet is in Content > Resources > Snippets,
And your stylesheet is in Content > Resources > Stylesheets, then your code should read "../Stylesheets/<whatever your stylesheet name is>"
Some mornings it just doesn't seem worth it to gnaw through the leather straps.
Re: Snippets - how to specifiy CSS/styles
Try this process:Andrew Heard wrote:Andrew - I don't see how Tools > Stylesheet Links assigns a stylesheet to a snippet. Could you explain please?Andrew wrote:... another way is to go to Tools > Stylesheet Links. That should enable you to link your stylesheet of choice to the snippet.
1) Open the snippet in question.
2) with the focus on that open snippet (i.e., you cursor is active in the snippet), go to Tools > Stylesheet Links. The Stylesheet Links dialog opens. On the right hand side, you will see all of your stylesheets. On the left, you will see the ones applying to this snippet.
3) Highlight the stylesheet on the right that you want to apply, and click the << button to apply it.
4) Click OK. The Stylesheet Links dialog closes, and the styles defined in the selected stylesheet should now be available while editing the snippet (but, of course, they will still be replaced by whatever stylesheet is used for the topic where the snippet is used).
This process does pretty much exactly what you do by manually editing the file in a text editor (i.e., it adds the link href line to your snippet), except you don't have to use the text editor.
Hope that helps.
Flare v6.1 | Capture 4.0.0
Re: Snippets - how to specifiy CSS/styles
Well, you can with the help of masterpages. See this KB article --> http://kb.madcapsoftware.com/default_CSH.htm#FMP1001FAndrew Heard wrote:If you have a master stylesheet you can't override the stylesheet for individual topics.
Stylesheet not being applied
Stylesheet not available
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: Snippets - how to specifiy CSS/styles
Lisa, you don't explicitly state it, and it's not in the article linked, but I assume that you are implying that you can link a stylesheet to the master page and use that...but when I have specified a master stylesheet, I cannot edit the stylesheet linked to the master page, so I'm not sure how that helps...?
Flare v6.1 | Capture 4.0.0
Re: Snippets - how to specifiy CSS/styles
There's another, similar KB article if you have multiple stylesheets in your project --> http://kb.madcapsoftware.com/default_CSH.htm#FMP1002F. I use just one stylesheet in all my projects. And if it's not specified in the article, you probably have to set the project to not have a master stylesheet (Project > Project Properties).
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
-
Andrew Heard
- Sr. Propeller Head
- Posts: 139
- Joined: Tue Aug 19, 2008 12:17 am
- Location: Perth, Western Australia
Re: Snippets - how to specifiy CSS/styles
Thanks for the knowledge base link, Lisa - didn't even know it was there!
And I'll try master pages when we have the upcoming release out of the way.
However, I'm a little confused - which is it, master stylesheet or no master stylesheet? I think the latter, if you have to use more than one stylesheet for your topics.
And I'll try master pages when we have the upcoming release out of the way.
However, I'm a little confused - which is it, master stylesheet or no master stylesheet? I think the latter, if you have to use more than one stylesheet for your topics.
LTinker68 wrote:Well, you can with the help of masterpages...Andrew Heard wrote:If you have a master stylesheet you can't override the stylesheet for individual topics.
Stylesheet not being applied
Stylesheet not available
LTinker68 wrote:... you probably have to set the project to not have a master stylesheet... (Project > Project Properties).
Some mornings it just doesn't seem worth it to gnaw through the leather straps.
Re: Snippets - how to specifiy CSS/styles
I think the option of a master stylesheet for a project was added to the Project Properties screen after that knowledgebase article was written. Initially, the Project Properties screen had just language settings, I think. Anyway, the benefit of leaving the master stylesheet declared is that brand new topics always have that as the default stylesheet, so if most of your topics use that stylesheet and only a few use the other one, then you might want to leave the master stylesheet in place and create a custom <html> tag that points to a second masterpage and that masterpage has the link to the second stylesheet. If you can't link the masterpage to a second stylesheet then you'll have to disable the master stylesheet option, in which case, every time you create a topic, you'll have to remember to select the stylesheet in the Add New Topic screen.
You might just have to play with the settings in a test project. Like I said, I always use just one stylesheet, so I don't know if leaving a master stylesheet defined means it'll always add that stylesheet link to the topic even if the topic is pointed to another stylesheet at creation, in which case you'd end up with two stylesheet declarations (which is perfectly "legal"), but the master stylesheet might be declared second which means it would take precedence. Maybe someone else can give more insight, but you could always test it in a test project.
Why do you have more than one stylesheet? Can you combine them into one? That would be easier.
You might just have to play with the settings in a test project. Like I said, I always use just one stylesheet, so I don't know if leaving a master stylesheet defined means it'll always add that stylesheet link to the topic even if the topic is pointed to another stylesheet at creation, in which case you'd end up with two stylesheet declarations (which is perfectly "legal"), but the master stylesheet might be declared second which means it would take precedence. Maybe someone else can give more insight, but you could always test it in a test project.
Why do you have more than one stylesheet? Can you combine them into one? That would be easier.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
-
Andrew Heard
- Sr. Propeller Head
- Posts: 139
- Joined: Tue Aug 19, 2008 12:17 am
- Location: Perth, Western Australia
Re: Snippets - how to specifiy CSS/styles
Thanks for that - clears things up a lot, and gives me options to try out.
In fact new topics created from my template already have the correct stylesheet automatically assigned.
I do have two stylesheets, and since there is no overlap at all, I prefer to keep them separate.
Cheers, Andrew
In fact new topics created from my template already have the correct stylesheet automatically assigned.
I do have two stylesheets, and since there is no overlap at all, I prefer to keep them separate.
Cheers, Andrew
Some mornings it just doesn't seem worth it to gnaw through the leather straps.
Re: Snippets - how to specifiy CSS/styles
If you use more than one stylesheet, completely avoid setting a master stylesheet - it will remove all other stylesheet links (in the output), whether they're set in your topic or your master page.
