Create variables for page name or user name

Hi folks,

I’m using sometime in my templates and snippets $pages->find('my-page') or $site->user('the-user') but since the pages can be renamed or maybe change the user to fetch, it could be easier if i can store them in variables that i can use everywhere and edit easily.

The question is how and where can i create these variables? config.php or models or…?

Thanks!

1 Like

For the pages, I’d use either the AutoID plugin or a custom read-only field with an unchangeable reference, rather than keeping track of this manually.

The user ID is not modifiable, so users should still exist unless they are deleted? But to define a user name, yes, you can use c::set() in your config, and retrieve with c::get() in your templates.

Ah nice plugin! Sadly unmaintained but i will use it with your structure-id plugin too.

Thanks!