New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access the App name & description settings within Twig #2337
Comments
There is performance considerations here. The If we add a Consider creating a utility component that injects the values you need, or alternatively extending twig to introduce the functionality as a filter or function. Some other options that we can consider:
Allowing you to share any variable across the entire front end, as we can do with Content and Mail Templates already. To make
|
I know I could always just continue to have a utility component / plugin that injects those variables, however I was thinking that it's a reasonably common use case to want to use those values in themes for OctoberCMS. A parallel to those settings would be the site name and tagline used in WordPress sites, utilized by themes in creating title tags for pages and copyright notices, as well as just general branding of the theme specific to the site its being used on. This way, themes wouldn't have to essentially duplicate these options in their own settings pages, they could just use the common values that would already be assigned for the backend. What are your thoughts on that? |
+1 |
It's unfortunate that we can't define a twig variable as a closure, allowing the Brand Settings to be lazy loaded, and also have no performance impact. This being the primary objection. Secondary is the separation of concerns, it is assumed that That said, it may be possible to pluck the app name from the backend brand settings, and push it to the CMS theme data for all themes. We just need a really good reason to do that.
This is probably where the mix up is coming from. Perhaps I am failing to see a reasonable use case beyond the fact that it is a familiar trait from WordPress. |
...being able to display the site name on any page, meta tag and so forth without having to create new functions should be enough reason :P |
@YahzeeSkellington, read the first paragraph of my last comment. Here is an example of defining the site name, and here is how its used. |
@daftspunk I'm using like clean theme but always return "October CMS". I set other name in theme.yaml, theme_fields.yaml, Backend Settings > App Name, config/app.php and still this.
Any idea? |
I'm have success change to this, in theme.yaml:
And removing theme_fields.yml. |
See https://octobercms.com/plugin/luketowers-essentialvars for my final solution to this |
I would like to be able to access the App Name and Tagline settings within my theme's Twig. As it stands right now, I have to add
to a custom component that I must include for every layout in order to be able to access these variables within my theme. I believe it would be helpful if they were accessible to the themes through Twig by default, similar to the other general variables available under the
this
object. Perhaps something like{{ this.app.name }}
and{{ this.app.tagline }}
?The text was updated successfully, but these errors were encountered: