1

I am using this on a custom component:

$url = index.php?option=com_content&view=article&catid=427&id=15106

Both

echo $url;
echo Route::_($url);

will output a friendly url.

I'm guessing this is coming from some J4 plugin and I should always use echo Route::_($url); for good practice, right?

1 Answer 1

1

Both of your assumptions are correct. Non-SEF URLs are converted to SEF by System - SEF plugin. But you should use SEF URLs in PHP code whenever possible. This will ensure proper URLs when the plugin is disabled and slightly improve performance when the plugin is enabled. For in-content URLs (e.g. URLs inside article text) it's the opposite. Non-SEF URLs should be used to prevent breaking when content item aliases or menu structures are changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.