I am trying to build a link on the fly. Originally I had a snippet calling a getChunk method and passing the values to the chunk. Inside the chunk was a line of code like:
[[~123? &rec=`[[+rec]]` &ab=`[[+ab]]`]]
This worked great to build my url, but I decided that a chunk was limiting the way I could display the data on the page, as I wanted to display data outside the area defined for my content. I then changed my snippet to place everything into placeholders. When I did this, I moved everything from my chunk to the resource, adding a prefix to all my tags. Everything looked great until I tried to use my link. It did not work. This code:
[[~123? &rec=`[[+prefix.rec]]` &ab=`[[+prefix.ab]]`]]
created a url that looked something like:
mypage?rec=%5B%5B%2Bprefix.rec%5D%5D&ab=%5B%5B%2Bprefix.ab%5D%5D
From my testing, I have found that passing values to placeholders, and then trying to reference those placeholders inside a call to make a url, the values are not passed. I have created a workaround by passing the placeholders to a snippet, which then runs makeurl. However, it would be nice to know if this is a bug that will be fixed in the near future, or if this is expected behavior?
I think it's expected behavior but I'm not sure.
It would probably be faster and more reliable to do it yourself in a custom snippet something like this:
[[!MyUrl? &docId=`123` &rec=`[[+prefix.rec]]` &ab=`[[+prefix.ab]]`]]
<?php
/*MyUrl snippet */
$fields = array (
'rec' => $scriptProperties['rec'],
'ab' => $scriptProperties['ab']
}
return $modx->makeUrl($scriptProperties['docId'], "", $fields, "full");
Glad you got it solved. The default ID is a nice addition.