Reusable Layout Menu?

I always seems to spend time making a nice button menu and using it on all my layouts by copy/pasting it after building it ... but it's absolutely terrible maintenance when you start adding/removing menu items.

Does any of the new versions of FileMaker help with this?

I always remember using Adobe Flash and they had a library that you could use the objects in different instances and you just went tot he library and updated the item and it was automatically updated wherever it was used.

I always dreamed of FileMaker having that function. Maybe it does now ... or similar?

Unfortunately you cannot add buttons in multiple layouts. You could use a button bar that you could populate in the beginning of an app the name of the button but this would also fail when you would need more buttons. So practically you have 2 options one is to have the menu in a card window so you will have to add edit in a single layout and the other is to use a webviewer with javascript as a menu like this JS MenuTree Add-on - Claris Marketplace

Hi @trevcis,

Welcome to The Soup. A reusable layout menu is a bit of a dream that we all have.

I experimented with a webviewer solution. It was data driven, and html buttons were generated which were interactive. Unfortunately, a webviewer is not a good solution as it does not work well in webdirect, and it responds much more slowly than buttons.

1 Like

I have deleted my previous post because I have revised my file and made the instructions and explanation clearer and the code better (hopefully :innocent:):

Here is a file with a context independent and DRY button bar. Use this button bar wherever you want in your solution. If you want to modify it later then you don't have to find every instance of it. You can enhance it easily and use it without getting headache.

[EDIT:]
Note: I keep a few buttons in stock that can be activated later via a custom function. See more in the file.

As you can imagine there will be some limitations: You can use icons for your initial buttons but this will not work for buttons you add later.
And don't use outlines for the buttons!

DRY Button Bar Demo.fmp12.zip (97,5 KB)

1 Like

I love this. Sharing improves your code

1 Like

I woke up this morning and realized one missing piece:
The ScriptParameter you want to pass to your action should be handled the same way like button labelling and custom hide condition.

So, here's version v3 of the file:
DRY Button Bar Demo_v3.fmp12.zip (98,2 KB)
[File replaced for passwordless login]

Your question @trevcis triggered me to create this little demo yesterday. And I definitely will use it in future. Thanks for the idea …

Here's my experiment with a navigation system based in a web viewer. Because it uses a web viewer that means that it sucks in lots of ways. However, HTML does lots of things easily, that are hard to do with FileMaker, which makes it tantalising.

Because we're able to dynamically control the content of the web viewer, everything can be controlled by scripts. In the demo you can change the formatting using ⌘-1, ⌘-2, etc. The Advanced and Simple buttons cause the menus to be replaced on the fly by loading a new data set into the web viewer. It is very flexible, and capable of much more than this file is demonstrating, but I don't think it is suitable for production use.

What we really want is some way to define one or more menu bars just as we can define custom menus. Then provide us with a new type of layout part (or extend the functionality of Navigation parts) which allows us to specify which menu bar to display in that part. In that way, we modify the menu bar in one place and it is instantly available across the entire system.

Navigator.fmp12.zip (198.4 KB)

1 Like

And here a slightly different approach: Instead of using a custom function for labels, a CF for script paramters and a CF for hide conditions now I use a custom function for each button.

In this CF you control everything around the corresponding button:
label
script parameter
hide condition
conditional formatting

In my demo file the button bar contains 10 buttons and 10 counter-segments.
You can choose between 2 versions of the button bar: One always shows all buttons in the same place, regardless of whether a button is hidden under certain circumstances. The other shows the buttons allways without a gap.

DRY Button Bar Demo_v4.fmp12.zip (100,6 KB)
[File replaced: I have corrected a comment in the button CFs and some text of the instruction.]

That's a cool concept, @Malcolm !

The only thing that bothers me is that the navigation bar flashes with every click.
And ... I don't know enough about HTML! Unfortunately! I should definitely change that!

I agree. The flash is not nice. I think that could be reduced by setting the background colour of the web viewer object and setting the background colour of the default web page but I'm not sure I could get rid of it entirely as there is a split second where there would be a blank space, and then the buttons are displayed.

It is this sort of issue that made me think that web viewer navigation was suitable for personal, or in-house projects but not suitable for products being delivered to clients.

1 Like

So - now I've improved the thing a bit more:

  • improved infos, instructions, explanations
  • I have fixed some bugs.
  • I have now turned the previous 10 buttons into 15.
  • Each occurrence of the button bar now shows the same button as active.
  • I have simplified the handling of the technically necessary hiding conditions so that it is also very quick and easy to add more buttons if you feel that 15 might not be enough in the long run.

To summarize, so that you don't have to gather all the information from my various posts:
The demo file shows a solution for a layout menu using a button bar. The buttons (labeling, script parameters, hiding condition and conditional formatting) can be configured centrally: There is a custom function for each button in which all of this can be configured.
To be able to add further menus to this layout menu later, the button bar simply contains more buttons than you need at the beginning. Only when these are given a label in the corresponding custom function do they become visible - in all layouts on which this button bar is located.

File:
Demo__LayoutMenu_centrally_configurable__v4.7.fmp12.zip (132,6 KB)
[File replaced at 07/29/2024: v4.7 now allows copying of the button CFs without sample data. So it is easier to start in your own file. And the file is now bilingual: German and English. Plus: The file name is now more meaningful.]

Best
Udo

1 Like

That would be really great!

For now you can use my demo file to accomplish this: Once you've copied the custom functions and the dispatcher script from my file to yours, make a copy of my file and rename the button bar custom functions and the dispatcher script.
Copy the renamed elements into your file: first the CFs, then the script, then the button bar. (I know you know this, but some people might not).
And now you have two such layout menus that you can configure separately from each other and distribute both as you wish in your file.

My typical approach is to use a card window with a portal pick list, where the portal is a virtual list. It populates from a key pairs table. When you select a menu item, it searches the key pair category field and if it finds a match, creates a new virtual list from the matching entries. If found count = 0, then that choice should conditionally branch into an executable path.

You can also do the same with value lists instead of a key pairs table by using ValueListItems to populate the pick list and the value list names to search for the next level of hierarchy. Takes a bit of discipline in naming as well as using exact match finds but it is both simple and highly portable.

2 Likes

Before the recent advent of the ctrl-k/cmd-k feature - and as an artifact of working on lots of solutions with well more than the 256 layout limit on the layout drop down, this same virtual list portal pick list technique got deployed but populated with layoutnames to be able to directly select layouts.