2

Can i use element queries in general.php file? I wanted to set loginPath based on entry query, like this:

'loginPath' => Craft::$app->entries->section('login')->one()->url ?? false,

Hovewer, i get error:

( ! ) Fatal error: Uncaught Error: Class 'Craft' not found in C:\xampp\htdocs\xxx\config\general.php on line 40
Piotr Pogorzelski
  • 1,286
  • 7
  • 18

1 Answers1

3

Add this at the top of config/general.php file:

use craft\elements\Entry;

And change your loginPath value to:

'loginPath' => function() {
   return Entry::find()->section('login')->one()->url ?? null;
},
Romain P.
  • 1,818
  • 16
  • 32