M
Maciej
Newcomer
First Post
Conversation Starter
5 posts
Hi,
I wanto to move Yaml header from page.header to config.file-name. Is it possible to all elements? It works for me with image but what about collections?
c ontent :
i tems : ' @self.siblings '
o rder :
b y : d ate
d ir : d esc
l imit : 10
a ktualnosci :
i tems :
' @page.children ' : / products/polish-functionality/news
o rder :
b y : d ate
d ir : d esc
l imit : 10
f ile_browser :
s ource : ' user://downloads/release/plf/ '
s ubmenu :
i tems :
' @page.children ' : / products/polish-functionality
o rder :
b y : f older
d ir : a sc
l imit : 10
talking about his section in docs https://learn.getgrav.org/16/basics/grav-configuration#config-variable-namespacing
Config Variable Namespacing
Paths to the configuration files will be used as a namespace for your configuration options.
Alternatively, you can put all the options into one file and use YAML structures to specify the hierarchy for your configuration options. This namespacing is built from a combination of the path + filename + option name .
For example: An option such as author: Frank Smith in file plugins/myplugin.yaml could be accessible via: plugins.myplugin.author . However, you could also have a plugins.yaml file and in that file have an option name called myplugin: author: Frank Smith and it would still be reachable by the same plugins.myplugin.author namespace.
last edited 02/10/21 by pamtbaau
M
Maciej
Newcomer
First Post
Conversation Starter
5 posts
Dear @pamtbaau is works somehow great but...
When I place this code:
{% set options = config . pf . content %}
{% set contents = page . collection ( options ) %}
{% set options = config . pf . news %}
{% set newss = page . collection ( options ) %}
{% for news in newss %}
< p > {{ news . title }} </ p >
{% endfor %}
{% for content in contents %}
< p > {{ content . title }} </ p >
{% endfor %}
to file default.md it all works correct. But when i transfer
{% set options = config . pf . content %}
{% set contents = page . collection ( options ) %}
{% set options = config . pf . news %}
{% set newss = page . collection ( options ) %}
to default.html.twig it doesn't work.
What am I missing?
last edited 02/11/21 by pamtbaau
M
Maciej
Newcomer
First Post
Conversation Starter
5 posts
I see that you placed "for" function also in default.html.twig. But I need sth more flexible and don't know if it is possible.
When I have this configuration in code it works fine:
default.pl.md
---
t itle : ' Polish Functionality - Starter Pack '
p rocess :
m arkdown : true
t wig : true
s ervicedesk_email : X XX
w ww : ' XXX '
d ocs : ' XXX '
a ppsource : ' XXX '
p roduct_logo : / user/files/logo/polish-functionality.svg
c ontent :
i tems : ' @self.siblings '
o rder :
b y : d ate
d ir : d esc
l imit : 10
a ktualnosci :
i tems :
' @page.children ' : / products/polish-functionality/news
o rder :
b y : d ate
d ir : d esc
l imit : 10
f ile_browser :
s ource : ' user://downloads/release/plf/ '
s ubmenu :
i tems :
' @page.children ' : / products/polish-functionality
o rder :
b y : f older
d ir : a sc
l imit : 10
---
{ % s et options = config.pf.content % }
{ % s et contents = page.collection(options) % }
{ % s et options = config.pf.news % }
{ % s et newss = page.collection(options) % }
{ % f or news in newss % }
< p>{{news.title }}</p>
{ % e ndfor % }
{ % f or content in contents % }
< p>{{content.title }}</p>
{ % e ndfor % }
but when I have two files is doesn't works.
first: default.pl.md
---
t itle : ' Polish Functionality - Starter Pack '
p rocess :
m arkdown : true
t wig : true
s ervicedesk_email : X XX
w ww : ' XXX '
d ocs : ' XXX '
a ppsource : ' XXX '
p roduct_logo : / user/files/logo/polish-functionality.svg
c ontent :
i tems : ' @self.siblings '
o rder :
b y : d ate
d ir : d esc
l imit : 10
a ktualnosci :
i tems :
' @page.children ' : / products/polish-functionality/news
o rder :
b y : d ate
d ir : d esc
l imit : 10
f ile_browser :
s ource : ' user://downloads/release/plf/ '
s ubmenu :
i tems :
' @page.children ' : / products/polish-functionality
o rder :
b y : f older
d ir : a sc
l imit : 10
---
{ % f or news in newss % }
< p>{{news.title }}</p>
{ % e ndfor % }
{ % f or content in contents % }
< p>{{content.title }}</p>
{ % e ndfor % }
and second: defaut.html.twig
{% extends " partials/page.html.twig " %}
{% set options = config . pf . content %}
{% set contents = page . collection ( options ) %}
{% set options = config . pf . news %}
{% set newss = page . collection ( options ) %}
{% block content %}
{{ page . content | raw }}
{% endblock %}
last edited 02/12/21 by Maciej