Format menu items based on conditions

This forum is for all Flare issues not related to any of the other categories.

Format menu items based on conditions

Postby nielsf on Wed Oct 11, 2017 4:38 am

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!
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby bianca_writer on Wed Oct 11, 2017 8:51 am

Can you include screen shots of the site to show what you want to change? Extra context is helpful. :)
bianca_writer
Propeller Head
 
Posts: 42
Joined: Tue Mar 15, 2016 9:57 am
Location: Irvine, CA

Re: Format menu items based on conditions

Postby nielsf on Thu Oct 12, 2017 3:42 am

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.
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Dave Lee on Thu Oct 12, 2017 5:25 am

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/
Dave Lee
Senior Propellus Maximus
 
Posts: 4968
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Format menu items based on conditions

Postby nielsf on Thu Oct 12, 2017 7:10 am

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)
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Dave Lee on Fri Oct 13, 2017 12:05 am

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
Dave Lee
Senior Propellus Maximus
 
Posts: 4968
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Format menu items based on conditions

Postby nielsf on Fri Oct 13, 2017 12:08 am

Thanks, I know - the issue is to get the class to show in there! :)
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Dave Lee on Fri Oct 13, 2017 12:38 am

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>   
Dave Lee
Senior Propellus Maximus
 
Posts: 4968
Joined: Mon Mar 05, 2007 8:33 am
Location: UK

Re: Format menu items based on conditions

Postby nielsf on Fri Oct 13, 2017 2:35 am

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.
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Jbleasdale on Fri Oct 13, 2017 3:41 am

Did you apply the styleclass to the TOC item in Flare?
Jbleasdale
Propeller Head
 
Posts: 40
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Postby nielsf on Fri Oct 13, 2017 3:46 am

Sure.
Are you running 2017 r2, Jbleasdale?
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Jbleasdale on Fri Oct 13, 2017 3:57 am

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.
Jbleasdale
Propeller Head
 
Posts: 40
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Postby nielsf on Fri Oct 13, 2017 4:03 am

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... :)
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby nielsf on Fri Oct 13, 2017 4:14 am

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.
nielsf
Propeller Head
 
Posts: 77
Joined: Mon Feb 02, 2015 5:44 am

Re: Format menu items based on conditions

Postby Jbleasdale on Fri Oct 13, 2017 6:35 am

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.
Jbleasdale
Propeller Head
 
Posts: 40
Joined: Tue Mar 21, 2017 3:35 pm

Re: Format menu items based on conditions

Postby Dave Lee on Fri Oct 13, 2017 7:36 am

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.
Dave Lee
Senior Propellus Maximus
 
Posts: 4968
Joined: Mon Mar 05, 2007 8:33 am
Location: UK


Return to Flare's General Discussion

Who is online

Users browsing this forum: Bing [Bot], chrisburden and 7 guests