<p>When you take a look at the Docs you'll see</p>

<blockquote>
  <p>See <a href="https://docs.craftcms.com/api/v3/craft-helpers-confighelper.html#method-localizedvalue" rel="nofollow noreferrer">craft\helpers\ConfigHelper::localizedValue()</a> for a list of supported value types.</p>
</blockquote>

<p>And that contains</p>

<blockquote>
  <ul>
  <li>$value (mixed) – The config setting value. This can be specified in one of the following forms:</li>
  <li>A scalar value or null: represents the desired value directly, and will be returned verbatim.</li>
  <li>An associative array: represents the desired values across all sites, indexed by site handles. If a matching site handle isn’t listed, the first value will be returned.</li>
  <li>A PHP callable: either an anonymous function or an array representing a class method ([$class or $object, $method]). The callable will be passed the site handle if known, and should return the desired config value.</li>
  <li>$siteHandle (string, null) – The site handle the value should be defined for. Defaults to the current site.
  Returns</li>
  </ul>
</blockquote>

<p>The interesting thing is <code>a function</code></p>

<pre class="lang-PHP prettyprint-override"><code>'activateAccountSuccessPath' =&gt; function(){
    return Entry::find()-&gt;section('myAccount')..... // do your thing
} 
</code></pre>

CC BY-SA 4.0
2019-03-21T21:39:15.753Z
2019-03-21T21:39:15.753Z
Robin Schambach
<p>I'm trying to set dynamic paths for values such as <code>activateAccountSuccessPath</code>.</p>

<p>This kind of code below from my <code>routes.php</code> file works very well:</p>

<pre><code>use craft\elements\Entry;

$myAccount = Entry::find()-&gt;section('myAccount');

return [
    $myAccount-&gt;type('user')-&gt;one()-&gt;uri . '/&lt;id&gt;-&lt;slug&gt;' =&gt; ['template' =&gt; '_myAccount/user']
];
</code></pre>

<p>But it seems that <code>craft\elements\Entry</code> can't be used at the top of <code>general.php</code> (which make sense...).</p>

<p>Any idea of a simple workaround to load Entry data at this time? Like this, I could set dynamic paths depending of the context and language.</p>

<p>I know I could already set paths like this:</p>

<pre><code>'activateAccountSuccessPath' =&gt; array(
     'fr' =&gt; 'mon-compte',
     'nl' =&gt; 'mijn-account'
),
</code></pre>

<p>But this is not enough, I would like the path match dynamically another existing URI in a Structure.</p>

<url><config>
How to load entries data in the General Configuration file?
# How to load entries data in the General Configuration file?

(Asked by: username_0 on 2019-03-21)

I'm trying to set dynamic paths for values such as activateAccountSuccessPath.
This kind of code below from my routes.php file works very well:
use craft\elements\Entry;

$myAccount = Entry::find()->section('myAccount');

return [
    $myAccount->type('user')->one()->uri . '/-' => ['template' => '_myAccount/user']
];

But it seems that craft\elements\Entry can't be used at the top of general.php (which make sense...).
Any idea of a simple workaround to load Entry data at this time? Like this, I could set dynamic paths depending of the context and language.
I know I could already set paths like this:
'activateAccountSuccessPath' => array(
     'fr' => 'mon-compte',
     'nl' => 'mijn-account'
),

But this is not enough, I would like the path match dynamically another existing URI in a Structure.

**Tags:** url, config

---

## 1 answers

### Answer by username_1 on 2019-03-21. Score: 3 | Accepted answer

When you take a look at the Docs you'll see

See craft\helpers\ConfigHelper::localizedValue() for a list of supported value types.

And that contains


$value (mixed) – The config setting value. This can be specified in one of the following forms:
A scalar value or null: represents the desired value directly, and will be returned verbatim.
An associative array: represents the desired values across all sites, indexed by site handles. If a matching site handle isn’t listed, the first value will be returned.
A PHP callable: either an anonymous function or an array representing a class method ([$class or $object, $method]). The callable will be passed the site handle if known, and should return the desired config value.
$siteHandle (string, null) – The site handle the value should be defined for. Defaults to the current site.
  Returns


The interesting thing is a function
'activateAccountSuccessPath' => function(){
    return Entry::find()->section('myAccount')..... // do your thing
}


---

