I have a component and I would like to prepare some URL.
The component display a list of categories, with a anchor tag for the category page. The category page can be selected in the component properties. After, the URL option is the slug.
For example, the category fruits : http://mywebsite.com/category/fruits
.
I could do the following : <a href="http://mywebsite.com/fruits/{{ category.slug }}">{{ category.name }}</a>
but this is not good, especially when I go to production.
For the page, I can use the |page
filter with {{ properties.categoryPage }}
, but I have to specifies the URL options, slug.
I think the best way would be to build a URL maker in the component PHP, but how?
Thanks.
The following code works :