You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在OpenCart 3.0.2.0主菜单中添加自定义链接

Hey there! Let's walk through how to add custom links to your OpenCart 3.0.2.0 main menu—super straightforward once you know the steps. I'll cover both the no-code backend method (perfect for default themes) and a code tweak if you're using a custom theme that overrides the default menu system.

This is the easiest way if you're using OpenCart's default theme or a theme that respects the admin menu settings:

  • Log into your OpenCart admin panel, then navigate to Design > Menus from the left sidebar.
  • You’ll see your existing main menu (usually labeled "Main Menu"). Click the Edit button next to it.
  • In the menu editor, hit the Add Menu button at the top right to create a new menu item.
  • Fill out the key fields:
    • Menu Name: The text that will show up in your main menu (e.g., "Our Story", "Return Policy").
    • Route: For internal pages, use OpenCart's route syntax (you can find this by opening the target page in admin and checking the URL—like information/information&information_id=4 for the default About Us page). For external links, just paste the full URL (e.g., https://your-brand-blog.com).
    • Status: Set to Enabled to make the link visible.
    • Sort Order: Adjust this number to position your link (lower numbers appear earlier in the menu).
  • Save your changes, then clear your store's cache (go to System > Maintenance > Cache and click "Clear").
  • Head to your store frontend—your new custom link should be live in the main menu!
Method 2: Code Tweak for Custom Themes

If the backend method doesn't work, it's likely your theme has a custom menu template. Here's how to add links directly:

  • Access your store files via FTP or cPanel File Manager. Go to catalog/view/theme/[your-theme-folder]/template/common/.
  • Open header.tpl (or sometimes menu.tpl, depending on your theme) in a plain text editor.
  • Find the loop that renders category menu items—it’ll look something like this:
    <?php foreach ($categories as $category) { ?>
        <!-- Existing category menu HTML here -->
    <?php } ?>
    
  • Insert your custom link right after (or before) this loop, matching the existing menu's HTML structure. For a simple top-level link:
    <li class="dropdown">
        <a href="https://your-custom-link.com" class="dropdown-toggle">Your Custom Link Text</a>
    </li>
    
    If you want a dropdown submenu, mirror the dropdown structure from the existing category items in the file.
  • Save the file, clear your store cache, and refresh your frontend—your new link should appear.

Pro Tip: Always back up your files before making code edits, and test changes on a staging site first if possible to avoid breaking your live store!

内容的提问来源于stack exchange,提问作者Akshay Vasu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:15:00