Page 1 of 1

How can I add a link in the menu?

Posted: Sat Jan 06, 2024 6:59 pm
by pivari
Hello,

I'm starting to use wondercms.
Can I add a link in the menĂ¹ (a simple link not a new page)?

thanks

fp

Re: How can I add a link in the menu?

Posted: Mon Feb 12, 2024 9:49 am
by NorfolkGreg
There's no way to do that with Wcms. As you have discovered, adding a menu item adds a page!

I can only think of a couple of approaches that might work:
  • Add an <iframe> to that new page that would contain the external site
  • Edit the template.php file in your theme to add the item immediately before or after the call to <?= $Wcms->menu() ?>

Re: How can I add a link in the menu?

Posted: Fri Aug 16, 2024 7:17 pm
by TinyCoding
Well, I guess you could edit the theme.php and wrap the PHP menu shorttag inside a flex or left/right alignment and that way, add custom links like that. Here's an example using HTML and CSS Flexbox.

HTML:

Code: Select all

<div class="flex-container">
  <div class="flex-item-left"><?php wcms menu tag here ?></div>
  <div class="flex-item-right">Your Links here</div>
</div>
CSS:

Code: Select all

.flex-container {
  display: flex;
  flex-direction: row;
  font-size: 30px;
  text-align: center;
}

.flex-item-left {
  background-color: #fff;
  padding: 10px;
  flex: 50%;
}

.flex-item-right {
  background-color: #fff;
  padding: 10px;
  flex: 50%;
}

@media (max-width: 600px) {
  .flex-container {
    flex-direction: column;
  }
}
Change the break-point from 600px into whatever you need.

Just remember the security aspects of a link if you care about things like noreferrer etc.

Example:
<a href="https://google.com" target="_blank">Go To Google</a>

If you need a class, just add class="name-of-my-css-class-here" before the href part. Same if you need to add an ID to the link for the purpose of, for example, scrolling to an existing section on a page/post on your page.

Then just add id="name-of-id" before the href. Just remember that you need to include id=#name-of-id" within the HTML element on your page as well.

Example: you have a text paragraph and you want the visitor to be automatically scrolled to that part, then add the id to the <p> tag like this: <p id="#name-of-id">text etc</p>

Best of luck.