OctoberCMS Static Pages plugin menu external links unable to open in new tab

- 1 answer

Ad

I have used OctoberCMSs' Static Pages plugin, everything seems to be working but as I have created static pages as well as menu and able to show them up front.

The only thing is not working for me is to open the links as External Tab..

I have put below code in my menu.htm partial but its not working.

[staticMenu MainMenu]
code = "main-menu"
[viewBag]
==

And to open link in new tab, I have done something like below.

<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ sub_item.url }}" {{ item.viewBag.isExternal ? 'target="_blank"' }}>{{ sub_item.title }}</a>

Here is the screenshot what I have done in backend to be able to open my menu link as new page.

enter image description here

The only thing is I am unable to open in new tab

What I am doing wrong here ?

Can anyone tell me ?

Thanks

Ad

Answer

Ad

You have an error in this line

<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ sub_item.url }}" {{ item.viewBag.isExternal ? 'target="_blank"' }}>{{ sub_item.title }}</a>

Should be

<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ sub_item.url }}" {{ sub_item.viewBag.isExternal ? 'target="_blank"' }}>{{ sub_item.title }}</a>
Ad
source: stackoverflow.com
Ad