This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
logical.guy7011287
Hi, I'm having problems with generating url links dynamically.
For some reason, /default gets added to the url unexpectedly. It's really messing up my page. How to fix it?
Code:
<a href="{{ 'administer/catalog-items_item'|page ~ '/' ~ item.id }}">
{{ item.title }}
</a>
Properties for administer/catalog-items_item.htm:
title = "Catalog Item"
url = "/administer/catalog-items/:item_id"
layout = "dashboard"
is_hidden = 0
The url generated for the link is:
/administer/catalog-items/default/1
Would really appreciate help with this asap.
Thanks in advance!
logical.guy7011287
Temporary workaround as follows:
<a href="{{ ('administer/catalog-items_item'|page ~ '/' ~ item.id)|replace({'/default/', '/'}) }}">
....blahblah....
</a>
daftspunky
default
is the value used when no value is supplied but is a requirement of the URL definition. Your options are either to make the parameter optional:
url = "/administer/catalog-items/:item_id?"
Or pass the parameter with the |page
filter:
<a href="{{ 'administer/catalog-items_item'|page({ item_id: item.id }) }}">
{{ item.title }}
</a>
1-5 of 5