H
H
happyer2018-02-07 13:27:57
PHP
happyer, 2018-02-07 13:27:57

What is the best way to make links using mvc?

Hello, suddenly a question arose about how to make the most convenient and optimized links (website navigation)?
I just don't really like the standard HTML link tag and I think there are ways to optimize it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Fedorov, 2018-02-07
@happyer

I didn’t quite understand the question, you don’t mean hardcoding with a hard indication where to send it, but dynamically? Then the answer is below:
Look in the direction of Aura Router routing with PSR 7 support, it has a generate () method that generates a link by route name and without hardcoding
https://vk.com/@autofay-pakety-rouitnga-na-php -sp...
the template is hardcoded and the link in the href is set href="/blog/<?=$post->id?>"like this rules for url (on /posts/ or /blog/), and display the link in the templates like this, and all links will automatically take into account the settings:/blog//pages/

href="<?= $generator->generate('blog.read', ['id' => 42]); ?>"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question