1

Writing a plugin and creating some links. Trying to use:

$url = craft::$app->urlManager->createUrl(['', 'state' => 'KS']);

to create a URL. I am expecting:

http://test.com/index.php?state=KS

but get:

http://test.com/index.php?p=actions&state=KS

That results in the following error:

HTTP 404 – Not Found – yii\web\NotFoundHttpException Template not found: actions

What is the p=actions that is being added to the url? I am a bit confused by this.

2

craft::$app->urlManager->createUrl will always return an action url because in the end this function does return UrlHelper::actionUrl($route, $params);

You want to create a basic site url so you need to do

UrlHelper::url('', ['state' => 'KR'] )
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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