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
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!

leonard12310
logical.guy7011287
logical.guy7011287

Temporary workaround as follows:

<a href="{{ ('administer/catalog-items_item'|page ~ '/' ~ item.id)|replace({'/default/', '/'}) }}">
    ....blahblah....
</a>
daftspunky
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>
logical.guy7011287
logical.guy7011287

This works, thanks. I must have somehow missed it in the documentation...

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.