1

I'm updating a Craft 2 plugin to Craft 3 and I'm having difficulties getting the Regex URLs working correctly. The eocs I'm using: Craft3 Docs
I used pluginfactory.io to create the basic craft3 plugin scaffold.
For context: the plugin name is expedweather.

This is the Route I'm trying to register:

$map_page = 'data/<range:\w+>/<peak:\w+>/<view:\w+>/<parameter:\w+>';
$event->rules[$map_page] = 'expedweather/forecastPanel';

In my DefaultController.php I've got this:

protected $allowAnonymous = ['index', 'forecast-panel'];

And I'm not sure what I'm doing wrong here but All I get is

HTTP 404 – Not Found – yii\web\NotFoundHttpException Page not found. ↵ Caused by: Invalid Route – yii\base\InvalidRouteException

I've made sure the plugin is enabled in the backstage.

1 Answer 1

1

Update I was able to solve half of my Problem:

Seems the Regex didn't like the "pure" slashes / in the URL between the parameters, once I escaped those, through backslashes like this: \/ it no longer gave me a yii\base\InvalidRouteException.

The new Problem I have now is that it can't find the action I'm referring to, see below:

// Path of File: ./src/Expedweather.php; in EVENT_REGISTER_SITE_URL_RULES

$map_page = 'data\/<range:\w+>\/<peak:\w+>\/<view:\w+>\/<parameter:\w+>';
$event->rules[$map_page] = 'expedweather/forecast-panel';

// Exert from ./src/controllers/DefaultController:
protected $allowAnonymous = ['index', 'forecast-panel'];
...
public function actionForecastPanel() {...}

An additional piece of info: I'm able to route to the DefaultController's index Function by removing /forecast-panel from the target action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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