# Simple menu in custom module

**URL:** <https://community.hubspot.com/t/simple-menu-in-custom-module/9584>\
**Category:** CMS Development\
**Created:** [July 25, 2018, 11:54am UTC](https://community.hubspot.com/t/simple-menu-in-custom-module/9584 "2018-07-25T11:54:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewisvrobinson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lewisvrobinson/32/50978_2.png) [@lewisvrobinson](https://community.hubspot.com/u/lewisvrobinson)\
**Post date:** [July 25, 2018, 11:54am UTC](https://community.hubspot.com/t/simple-menu-in-custom-module/9584/1 "2018-07-25T11:54:40Z")

</div>

Hey all 👋

I’m trying to use the _simple menu_ field type in a custom module to create a customisable link. I’m having trouble when it comes to handling the different types of menu items. For example the **URL Link** returns the value of the field to

**linkUrl**

, but if the menu item is a **Page link with URL parameter** the

**linkUrl**

returns

**null**

and I can’t see any other fields on the object that I can use to get the url of the page.

This is what I’m working with:

```auto
<a href="{{ module.button.link[0].linkUrl }}{{ module.button.link[0].linkParams }}" class="{{ module.button.type }} button--block">
  {{ module.button.link[0] }}
</a>

```

Ideally what I need to be able to do is change the href of the link to URL defined in the menu item, regardless of the _type_ of the menu item. Any idea how I can acheive this? I’m thinking that I must be missing something…

---

<div class="post-metadata">

**Author:** ![lewisvrobinson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lewisvrobinson/32/50978_2.png) [@lewisvrobinson](https://community.hubspot.com/u/lewisvrobinson)\
**Post date:** [July 26, 2018, 2:34am UTC](https://community.hubspot.com/t/simple-menu-in-custom-module/9584/2 "2018-07-26T02:34:09Z")

</div>

Ok, I think I’ve figured it out. I can use the simple menu field (in this case **link** ) to get the desired URL string. Just in case anyone else is wondering…

If the menu item is a **URL Link** I can just use the **linkUrl** value. Easy.

`{{ module.button.link[0].linkUrl }}`

If the menu item is a **Page link with URL parameter** I need to use the **page\_by\_id()** function to get the absolute URL of the specified page by passing it the **pageLinkId**. 🙌

`{{ page_by_id(module.button.link[0].pageLinkId).absolute_url }}`

If there’s a better/easier way to do this, I’m all ears!
