# Using field options and routes to build different pages

**URL:** <https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695>\
**Category:** Questions\
**Created:** [June 24, 2019, 10:11am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695 "2019-06-24T10:11:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgmac1106](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jgmac1106/32/6862_2.png) [@jgmac1106](https://forum.getkirby.com/u/jgmac1106)\
**Post date:** [June 24, 2019, 10:11am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/1 "2019-06-24T10:11:15Z")

</div>

I want to use the same template for my notes, replies, bookmarks, follows but then be able to have these go to different pages.

This is my general strategy and wanted to ask if I am heading down the correct path.

Start here:

```
fields:
  category:
    label: URL
    type: url
  category:
    label: Type
    type: select 
 options:
      mention
      reply
      bookmark
      following

```

(Haven’t figured out this part yet but thinking)

```
    <?php
    return [
        'postype' => [
            'reply' => 'u-in-reply-to',
            'bookmark' => 'u-bookmark-of',
            'following' => 'u-follow-of',
        ]
    ]

```

Then I need to try and echo both the link and the selection field…I know this PHP is probably way off (advice welcome)

`<a class="<?= option('posttype')>?>" href="<?= url('link') ?>"><?= url('link') ?></a>`

Then I want to use routing to say “If a note or reply to go to this page, if bookmark to this page, and if following to this page”

I do not know how I would write the routes to specific pages based on the selection of either the Option or on how the tempaltes rendered.

Does this all sound possible? Am I on the correct track?

```auto
return [
    'routes' => [
        [
            'pattern' => 'posttype(:any)',
            'action' => ???????????????????
                ]);
            }
        ]
    ]
]

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 24, 2019, 10:18am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/2 "2019-06-24T10:18:54Z")

</div>

> [@jgmac1106](#):
>
> fields: category: label: URL type: url category: label: Type type: select options: mention reply bookmark following

This won’t work, because you are using the same field key twice.

> [@jgmac1106](#):
>
> \<?= option('posttype')\>?\>

You are trying to echo an array, that won’t work. You would have to get the index of what you want here, e.g. `option('posttype')['reply']`.

> [@jgmac1106](#):
>
> \<?= url('link') ?\>

What does this refer to?

---

<div class="post-metadata">

**Author:** ![jgmac1106](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jgmac1106/32/6862_2.png) [@jgmac1106](https://forum.getkirby.com/u/jgmac1106)\
**Post date:** [June 24, 2019, 10:26am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/3 "2019-06-24T10:26:42Z")

</div>

That would be the link from

```auto
fields:
  category:
    label: URL
    type: url

```

The ultimate goal is just  
have a link and then a select box where people can choose the link type and this ends up as:

```
    <a class="u-in-reply-to" href="#">link</a>
    <a class="u-bookmark-of" href="#">link</a>
    <a class="u-follow-of" href="#">link</a>

```

Then using routes I will build a page that displays all my notes and replies, a page for bookmarks, and a page for my follows.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 24, 2019, 10:28am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/4 "2019-06-24T10:28:52Z")

</div>

Ok, but you called the field `category`, so you would fetch it with `$page->category()`. But as I said, two times `category` does not work.

---

<div class="post-metadata">

**Author:** ![jgmac1106](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jgmac1106/32/6862_2.png) [@jgmac1106](https://forum.getkirby.com/u/jgmac1106)\
**Post date:** [June 24, 2019, 10:30am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/5 "2019-06-24T10:30:44Z")

</div>

Yes perfect, thank you so much @texnixe!!

Will take me some time to figure out how to build. Figure I would ask now to catch obvious mistakes like using category.

I was just copying examples from the cookbook and trying to tweak.

---

<div class="post-metadata">

**Author:** ![jgmac1106](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jgmac1106/32/6862_2.png) [@jgmac1106](https://forum.getkirby.com/u/jgmac1106)\
**Post date:** [June 24, 2019, 11:29am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/6 "2019-06-24T11:29:34Z")

</div>

This is what I will use in the blueprint

```auto
fields:
  link:
    label: URL
    type: url
  postype:
    label: Type
    type: select 
      options:
         mention
         reply
         bookmark
         following

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 24, 2019, 11:38am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/7 "2019-06-24T11:38:15Z")

</div>

Your indentation level looks incorrect. `options` should be on the indent level as type.

```auto
fields:
  link:
    label: URL
    type: url
  postype:
    label: Type
    type: select 
    options:
      mention
      reply
      bookmark
      following

```

---

<div class="post-metadata">

**Author:** ![jgmac1106](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jgmac1106/32/6862_2.png) [@jgmac1106](https://forum.getkirby.com/u/jgmac1106)\
**Post date:** [June 25, 2019, 11:17am UTC](https://forum.getkirby.com/t/using-field-options-and-routes-to-build-different-pages/14695/8 "2019-06-25T11:17:37Z")

</div>

@texnixe

Congrats on the release and thanks for the work on the documents.

Would sorting [https://getkirby.com/docs/cookbook/content/sorting](https://getkirby.com/docs/cookbook/content/sorting) make more sense to build pages based on post types better than routing?

Can you sort and exclude when you build a page model?
