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

This forum is for all Flare issues related to styles, stylesheets and XML.

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

Postby M33R4 on Wed Apr 07, 2021 5:30 am

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.
Newbie to MadCap Flare
M33R4
Sr. Propeller Head
 
Posts: 107
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

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

Postby Dave Lee on Wed Apr 07, 2021 5:44 am

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

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

Postby M33R4 on Wed Apr 07, 2021 9:25 am

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: 107
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

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

Postby M33R4 on Tue Sep 14, 2021 2:47 am

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:


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
M33R4
Sr. Propeller Head
 
Posts: 107
Joined: Wed Oct 07, 2020 7:58 am
Location: UK

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

Postby Dave Lee on Tue Sep 14, 2021 8:30 am

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


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 8 guests