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?
return [
'routes' => [
[
'pattern' => 'posttype(:any)',
'action' => ???????????????????
]);
}
]
]
]
This won’t work, because you are using the same field key twice.
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']
.
What does this refer to?
That would be the link from
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.
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.
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.
This is what I will use in the blueprint
fields:
link:
label: URL
type: url
postype:
label: Type
type: select
options:
mention
reply
bookmark
following
Your indentation level looks incorrect. options
should be on the indent level as type.
fields:
link:
label: URL
type: url
postype:
label: Type
type: select
options:
mention
reply
bookmark
following
1 Like
@texnixe
Congrats on the release and thanks for the work on the documents.
Would 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?