Format menu items based on conditions

This forum is for all Flare issues not related to any of the other categories.
Post Reply
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Format menu items based on conditions

Post by nielsf »

Hi,
I maintain a beta site (kind of a staging site) and the "real" site. For users of the beta site, it could be useful to know that the page they are reading only exists on the beta site (so they don't get nervous).
I'm already using conditions to keep the pages from being published to the official site. I thought it would be nice to add a color to the menu item as well.
Is that even possible? As far as I can see, information about conditions in the TOC is not transferred to the html, but only used for selection of pages by the target.
:idea: Ideas are welcome!
-----
Flaring in Copenhagen, Denmark
bianca_writer
Propeller Head
Posts: 54
Joined: Tue Mar 15, 2016 9:57 am
Location: Los Angeles, CA

Re: Format menu items based on conditions

Post by bianca_writer »

Can you include screen shots of the site to show what you want to change? Extra context is helpful. :)
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Sure thing - a picture is worth 1000 words, and all that:
MenuConditionalFormat.png
The menu item in the red box should have a different color than the other menu items, to set it apart.
(Of course the menu item "Internal pages" would be a candidate as well, but you get the idea.)
-Niels
You do not have the required permissions to view the files attached to this post.
-----
Flaring in Copenhagen, Denmark
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Format menu items based on conditions

Post by NorthEast »

You can't do this using conditions (as they're not present in the output), but you can set a style on a menu item, and get this to display in the top nav skin / menu proxy.
See:
* This post: viewtopic.php?f=6&t=29402&p=128508#p128508
* This article: https://www.linkedin.com/pulse/how-i-co ... tte-gagne/
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Thanks, Dave Lee, and also Jbleasdale who suggested going this route in a private IM.
I will look into this. I will need some time to concentrate on it, because I can't see how the styles named in the skin and defined in the css get selectable in the toc entry properties. Preliminary experiments gave me nothing.
I will let you all know how I fare... 8)
-----
Flaring in Copenhagen, Denmark
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Format menu items based on conditions

Post by NorthEast »

nielsf wrote:Thanks, Dave Lee, and also Jbleasdale who suggested going this route in a private IM.
I will look into this. I will need some time to concentrate on it, because I can't see how the styles named in the skin and defined in the css get selectable in the toc entry properties. Preliminary experiments gave me nothing.
I will let you all know how I fare... 8)
In the TOC entry properties General tab, select the Style Class that you've created.
Screenshot from the article:
Image
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Thanks, I know - the issue is to get the class to show in there! :)
-----
Flaring in Copenhagen, Denmark
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Format menu items based on conditions

Post by NorthEast »

nielsf wrote:Thanks, I know - the issue is to get the class to show in there! :)
Ah, Ok. Step 3 of the article tells you to put it the <Style> block inside the <Styles> block.

But if you're using a brand new skin, then you won't have a <Styles> block, you'll just have an empty <Stylesheet /> line.

So <Style> goes inside <Styles>, and that goes inside <Stylesheet> - so the structure you need in the skin is:

Code: Select all

  <Stylesheet>
		<Styles>
			<Style
				Name="TocEntry">
				<Classes>
					<StyleClass
						Name="MyStyle"
						Custom="true">
						<Properties>
							<Property
							Name="FontSize">1em</Property>
						</Properties>
					</StyleClass>
				</Classes>
			</Style>	
		</Styles>	
  </Stylesheet>	
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

OK, now I have time to experiment. I've added the style class in the skin, and the style shows up in the toc entry properties.
I've added the style:

Code: Select all

.TOCbeta > a:after
{
   content: "\f126"; /*code fork */
   font-family: FontAwesome;
   vertical-align: super;
   position: relative;
   left: 5px;
   bottom: 2px;
   color: #ff7045;
   font-size: smaller;
}
However, when I generate the project, the TOCbeta class is not applied to the <li> tag. I had expected the menu to be like this:
menubetastyle.png
and look like this:
menubeta.png
(This pic is from my adding the class manually in the Chrome's Inspect pane).
But there is no indication of my having selected the TOCbeta style class for the menu item anywhere.
Now how can that be. I have a guess: I am running 2017 r2, and the menu generation was changed completely to be generated on-the-fly and not pre-packaged by the target generator. This has screwed with several of my nifty add-ons that required the presence of a menu structure from the get-go.
Are you running 2017 r2?
You do not have the required permissions to view the files attached to this post.
-----
Flaring in Copenhagen, Denmark
Jbleasdale
Propeller Head
Posts: 58
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Post by Jbleasdale »

Did you apply the styleclass to the TOC item in Flare?
Joe Bleasdale

My Linkedin

Image
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Sure.
Are you running 2017 r2, Jbleasdale?
-----
Flaring in Copenhagen, Denmark
Jbleasdale
Propeller Head
Posts: 58
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Post by Jbleasdale »

Yes I am.

I remember adding the styles was easy, but I did take a little bit of time to get them to apply properly.

Looking at your code, I think you are trying to add the style to a whole book, whereas mine is an individual topic in the TOC... Thats the only difference I can think of.
Joe Bleasdale

My Linkedin

Image
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Hi,
Not sure how you arrive at the conclusion that my code should apply to the whole book? Now that would be easy!
No, I only apply it to select TOC entries.
I create the toc style in the skin.
I create the style class in the css.
I apply the style to the TOC entry in its property page.
I generate.
As far as I can tell, that ought to be it.
But I must be doing something wrong since you are also running Flare 2017 r2. So - back to the drawing board... :)
-----
Flaring in Copenhagen, Denmark
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Format menu items based on conditions

Post by nielsf »

Sorry - now it seems to work! I generated it again...
OK, it almost works! When the menu item is selected, it loses its new formatting.
Works:
menubetaNotSelected.png
Doesn't work (selected):
menubetaSelected.png
Looking in the code, the TOCbeta class is stripped from the entry when it is selected.
Anyway, my initial question was answered - thanks!
You do not have the required permissions to view the files attached to this post.
-----
Flaring in Copenhagen, Denmark
Jbleasdale
Propeller Head
Posts: 58
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Post by Jbleasdale »

Glad to hear its working (kind of).

The book I was referring to was the TOC book (a collection of topics). Not the whole project.

The styling issue is likely because there is some CSS that overrides the TOC style when the item is selected. The dev tools should tell you that.
Joe Bleasdale

My Linkedin

Image
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Format menu items based on conditions

Post by NorthEast »

I had a look - when you select an item from the TOC in the menu proxy, it will not include the TOC style class for the 'book' topics only (book is any topic with a child topic).
That not only applies to the selected topic, but also all child and parent topics (that are books too) in that part of the menu tree. Sibling books topics are ok.

When I suggested this solution, I thought it worked ok - but seems like it works fine for the top nav menu, but not properly for menu proxies.
Post Reply