♪ calling or not calling a new twig block

For the blog section of the site, I created a section above the navbar.
Under this line, the code (the above section is the section I added above the menu bar to display a logo etc… it’s named ‘section id="above’

—html
{% block header %}

{% block above %}


{% include ‘partials/cookiespolicy.html.twig’ %}
  • francois-vidit.fr



  • francois-vidit.fr



  • {% endblock %}
        <header id="header">
            <div id="colorgradient"></div>
            <div id="logo"> 
                <h3><a href="{{ base_url == '' ? '/' : base_url }}"><i class="fa fa-home"></i></a></h3>
            </div>
            <div id="navbar">
                {% block header_extra %},{% endblock %}
                {% block header_navigation %}
                {% include 'partials/navigation.html.twig' %}
                {% endblock %}
                <span class="panel-activation sb-toggle-left navbar-left menu-btn fa fa-bars"></span>
            </div>
        </header>
        {% endblock %}
    
    
    This section is perfect for the blog section, but annoying for *modular pages*.
    
    I created a `{% block above %}` and `{% endblock %}` with the idea of *calling* and avoid *calling* this part on pages that do not need it, like *modular ones*...
    
    I have never done that before, it's not that I am afraid, it's just that I don't know where look to do it properly: I mean this has to be done properly as I feel this is the key point of the templating structure of GRAV...
    
    Thanks in advance for the light... ☆
    
    I precise that I am writting from France, and it's nignt right now here, so that I won't be able to react right now as I have to sleep ☆ but I'll resume tomorrow.
    Thanks in advance for considering this request …
    1 Like

    ☆ i am back now!

    1 Like

    Hi @tidivoit sorry haven’t seen your post before you linked it :wink: I guess you placed your code in the partials/base.html.twig. If yes the modular.html.twig extends this and you can add there

    {% block above %},{% endblock %}
    

    which will override you previously defined block (more on this here http://twig.sensiolabs.org/doc/tags/extends.html). Otherwise you might like to have your above block only for blog pages, then why not putting it in blog.html.twig. That’s the best place for that.

    ☆ Thank you immensely for the answer: I don’t know what to do with this above section !

    I just tried the assets method but without success so far.

    I wrote a above.css placed in mytheme/css/above.css
    (I am under antimatter modified by my theme)

    #body #sb-site #above section {
    	display: none;
    }
    

    In the modular.fr.md, I placed an an asset like this

    {assets:css}
    above.css
    {/assets}
    

    It did not worked at all.

    I tried in a subfolder like showcase.fr.md: same result…

    Anyway, I am going to have a look at what you are trying to explain to me.

    Thanks again ♪

    1 Like

    @tidivoit :slight_smile: Since I now (partially) understand your problem, I really think you can solve it with the above approach placing the above block at the right place in the Twig code. If you don’t know what to do, the best is name your template files, what is located where including the required lines.

    Thank you @Sommerregen

    I am trying now to move above to blog.html.twig as it is the place where it should be as you said.

    I am discovering twig and am disappointed because I cannot really understand yet, with just the Grav documentation or the official SensioLabs Twig documentation how it works.

    I promise that if I succeed I will try to propose something to learn.get.grav.org as I already did this morning

    1 Like

    ♪ HURRRRRRAHHHH ☆ hHhHhHuUuUuURrRrAAaAaaHhHHh !!! ☆ aAHh !!! ☆ ♪ ☆

    Thank to YOU, again it beautifully worked, and I feel that I have understood a lit bit more of the logic of Grav and Twig…

    It’s absolutly fascinating ! (and what a pleasure when succeeding…

    Thank you Sommerregen … Now I am able to be flexible adding here this, not there etc … etc… Extraordinary!

    You are right again… May be I can also create a above.html.twig file and place it in mytheme/partialsand call it that way…
    I have to try … There is no reason to make the blog part heavy

    That’s really great and I really like to see other making progress! Due to its flexibility Grav it isn’t easy, but you have learned a lot already. For theming I can recommend you to read the Twig documentation ( http://twig.sensiolabs.org/documentation ) carefully, since exept of some specialities (additional functions, filters and variables) that’s Twig and nothing more.

    You are right, too. You can put the code in a above.html.twig and reference it in other files. In this case you made your code re-usable. Nice!

    I would not have been to get to such a point without your active support… ♪
    Thank you again ☆

    I am going to propose something in the learn section in order to make things may be easier to get at first…

    The more I get into grav the more I see what it is: a toolbox that aims at staying simple but with the maximum of flexibility and efficiency.

    Experiencing other themes with downloading skeletons, I noticed that lots of the themes are a lot heavier than antimatter: especially those which are making a use of more complex librairies…

    Do you an opinion / recommandations ?

    Frankly, now that I have been able to see all these examples, I am able to make really the multilingual site that I was aiming at and I have no word to express the joy of that thought ♪

    @tidivoit
    [Grav is] a toolbox that aims at staying simple but with the maximum of flexibility and efficiency.
    That’s a good definition and maybe worth to put in the getgrav.org website :wink:

    Well, it is difficult for me to give you a recommendation. I really like antimatter and if you like it that’s a good start. However there are other themes, which have really nice features, too (the user menu in Landio for example). In this case I usaually look at the code and how it is implemented. Then I copy the needed lines, modify them and enrich my theme. That’s how I’m doing it. In this way (starting from a light-weight theme and progressively extending it) you have full control over what you need and what not and besides you learn how the feature is realized :slight_smile:

    Thanks again ♪

    I downloaded Landio skeleton to have a close look: is that the transparent effect of the menu that you like?
    What part did you inspired from?

    I looked a little bit to it’s structure: its uses bootstrap… but contrarily to other bootstrp theme, it’s not so heavy ☆

    Personnaly, what impressed me is its quality especially the video: not only the video itself, but the real experience that it is, the way it is displayed.

    I have also been impressed by the number of images (images section) of the logo to render it correctly on any platform.

    Though It’s just one modular page, I wonder what It becomes with several pages: no blog for instance… That could be adapted from the antimatter structure

    Comparated to antimatter, it’s looks even much more professionnal… but it’s a real designer work to be able to put all the design together into a meaningful result.