SKIN ToolBar-icon needs to link to a page in project?[FIXED]

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
M33R4
Sr. Propeller Head
Posts: 128
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

SKIN ToolBar-icon needs to link to a page in project?[FIXED]

Post by M33R4 »

I have an icon in my ToolBar named New.

When the user clicks this icon, I want them to be taken to the New topic page within the project.

The button sits here:
Project > Skins > ToolBar > Styles > New

May I have a dummies' guide on how to do this please :?:

Many thanks.
Last edited by M33R4 on Wed Oct 06, 2021 8:06 am, edited 1 time in total.
Newbie to MadCap Flare
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: SKIN - icon to link to a page in project?

Post by NorthEast »

Use javascript in the toolbar event.

For example, this will try to open a file called NewTopic.htm in the same folder:

Code: Select all

window.location.href="NewTopic.htm";
However, that only works if the file is in the same relative position. But if you keep topics in different folders, then the relative path to NewTopic.htm is not going to be fixed.
A more robust solution would be to use an absolute link to the topic in its published location; e.g.

Code: Select all

window.location.href="https://your-site.com/yourhelp/Content/NewTopic.htm";
M33R4
Sr. Propeller Head
Posts: 128
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

Re: SKIN ToolBar - icon needs to link to a page in project?

Post by M33R4 »

Thank you Dave Lee.

I don't have my project published yet hence wanted to link the icon to an internal topic page.

I inserted the JS into one icon but don't know why the same JS got inserted in my other icons :shock: ...meaning when the user clicks on any of the icons they will land on the same page.
Newbie to MadCap Flare
M33R4
Sr. Propeller Head
Posts: 128
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

Re: SKIN - icon to link to a page in project?

Post by M33R4 »

Dave Lee wrote:Use javascript in the toolbar event.

For example, this will try to open a file called NewTopic.htm in the same folder:

Code: Select all

window.location.href="NewTopic.htm";
However, that only works if the file is in the same relative position. But if you keep topics in different folders, then the relative path to NewTopic.htm is not going to be fixed.
A more robust solution would be to use an absolute link to the topic in its published location; e.g.

Code: Select all

window.location.href="https://your-site.com/yourhelp/Content/NewTopic.htm";

I've added the code to the Event field on my ToolBar skin.
The page I want a click to take the user to is named toc.htm.

toolbarskinsearchaddress.PNG
This toc.htm page is saved as 1st level within my Content Explorer:
tocincontentexplorer.PNG

However, on publication, when I click on the Search icon it's giving me a URL not found page:[/color]
filenotfounde.PNG

Where am I going wrong please :?:

Thanks.
You do not have the required permissions to view the files attached to this post.
Newbie to MadCap Flare
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: SKIN ToolBar - icon needs to link to a page in project?

Post by NorthEast »

That will only work form topics that are in the same folder - so it'd work from home.htm, but would not work in a topics that are in a sub folder.

That's why I suggest using an absolute link.
M33R4
Sr. Propeller Head
Posts: 128
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

Re: SKIN ToolBar - icon needs to link to a page in project?

Post by M33R4 »

Good news is that same code eventually started working :)
Newbie to MadCap Flare
Post Reply