How can I create dynamic template?

I would like to create virtual redirector for affiliate links.
In site settings I have field that create path for links (for ex. ‘out’ or ‘go’ or ‘link’) and inside review blueprint i have two fields affiliate_link and terms_link.

In templates I’m create affiliate links in this way:
<?= $site->url() ?>/<?= $site->affiliate_redirect_link_folder() ?>/<?= $review->uid() ?>

And have template redirect.php that I would like to made dynamic…
Is it possible?

I don’t know, because I don’t understand at all what you are trying to achieve. How does the redirect.php template fit into what you explain before. What sort of fields are these fields that you describe and what sort of content do they contain?

The logic was

Review blueprint have fields
Review_link
Terms_link
But also review have many other fields

So the idea was not to create different Blueprint Links and attach them to Review
But create some virtual router that will catch slug from Site blueprint and when full url will be like this
Somesite.com/(site field slug)/(review_link)

Redirect to page that have template Redirect
Or even use virtual route without Redirect template.

I need to to create ability made redirection to external site by parsing url link that uses
Site field as slug and review fields as the mask that will give me information where I need to do redirect

For example
Review field
Uid = Test
Affiliate_link = http://google.com

Site field
Redirect_folder = go

So the link is: site.com/go/test
When I click this link I need to be forwarded to google.com

maybe my plugin can help: https://github.com/bnomei/kirby3-redirects

it can store redirects from routes to routes or external pages. the redirects tables is stored as structure.

you could use the page update and delete hooks to check if changed page matches the review template.
if it does match read and update the redirects table structure to reflect the changes made.

1 Like

thanks, its great, but it is a little bit different thing for my needs.