Spen Posted August 9, 2019 Share Posted August 9, 2019 Hello there, Is it possible to add an external link to the main menu? This would be the site we would like to add this to? Regards, Spencer Link to comment Share on other sites More sharing options...
dragan Posted August 10, 2019 Share Posted August 10, 2019 Which "main menu"? In your frontend-template, or in the backend? Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 11, 2019 Share Posted August 11, 2019 I use the following to get a redirect in the frontend to url outside of processwire, in my case to my shopping cart which is not part of processwire, but it can be any url as you can see below. What I did was add a page that uses a redirect template to the outside url 1- I made a template called redirect.php In the template I have this code: <?php $url = "https://www.xxx.xx/"; $session->redirect($url); ?> 2 - I added a page which uses the redirect template on the same level as the other pages that appear in the main menu. Works like a charm for me. Link to comment Share on other sites More sharing options...
wbmnfktr Posted August 11, 2019 Share Posted August 11, 2019 You could also use either of these methods/modules: Module Menu Builder - create custom menus, including external links. You decide what will be in it. Module Jumplinks - just create the pages you want and create redirects within Jumplinks (/old/path -> https://wherever.test/). It's easier and it handles more than redirects - like 404s and counts every click on your redirects. 1 Link to comment Share on other sites More sharing options...
Larhendiel Posted October 24, 2022 Share Posted October 24, 2022 Yet aaanother google search brought me to this forum. I would like to add more elements to navbar. I just dont know how. They appear to be rendered through this thing inside a loop: if ($child->checkbox == 1) { new MenuItem([ "page" => $child, "isSelected" => $child->id == $this->page->id || $this->isParentOfCurrentPage($child), "clickDisabled" => $this->isClickDisabled($child) ]); } But how do I add more items? I've also have this comment added by previous dev, but I know not what to do with this: // top navigation consists of homepage and its visible children Link to comment Share on other sites More sharing options...
Jan Romero Posted October 25, 2022 Share Posted October 25, 2022 Hi @Larhendiel, there appears to be some custom abstraction that is not part of ProcessWire called "MenuItem". There should be a place where these MenuItem objects are used to generate the actual markup ("<a href" etc.). You may be able to just hardcode your external link there, or build something that aligns more closely with the current system. From the look of it, a MenuItem takes a Page object to generate a link, so unless there already is a way to give it an external address, you’ll have to build it yourself. If you need more concrete assistance, please post the class definition of MenuItem and the code that renders the menu markup (please use the code function for this, it’s the button with the "<>" symbols on it). Link to comment Share on other sites More sharing options...
protro Posted May 4, 2023 Share Posted May 4, 2023 Using Rockfrontend + Latte, I was able to add an external link using the navmenu by writing a condition if the page title matched a string: {* build the menu *} {foreach $navItems as $item} <li n:class="$rockfrontend->isActive($item) ? uk-active"> {if $item == $home} <a href="{$item->url}">Home</span></a> {elseif $item->title == "MyMenuItem"} <a href="https://example.com" target="_blank">{$item->title}</span></a> {else} <a href="{$item->url}">{$item->title}</span></a> {/if} </li> {/foreach} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now