Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Displaying text in menu bar

Started by Lewis 9 years ago · 1 replies · 789 views
9 years ago

I'd like to display a telephone number in the menu bar on my website. I did succeed a while ago, but it wasn't responsive (i'm not so good with coding), and it didn't work well, especially on smaller screens.

If anyone has a solution to this, that would be great!

My website

The theme i'm using is Woo, if that matters.

Thanks!

9 years ago

Hi @lewissn, here is one way:

In your site config file add a menu entry without a URL, like this:

YAML
      - text: Subscribe
        link: "#subscribe"
      - text: 123-456-7890
        link: ""

Then find this bit of Twig in your navigation.html.twig template file (in Partials template folder):

TWIG
<a href="{% if "#" in mitem.link %}{{ base_url_absolute }}/{{ mitem.link }}{% else %}{{ mitem.link }}{% endif %}" {% if not "#" in mitem.link  %}class="smoothscroll"{% endif %}>{{ mitem.text }}</a>

And change it to:

TWIG
{% if mitem.link %}
    <a href="{% if "#" in mitem.link %}{{ base_url_absolute }}/{{ mitem.link }}{% else %}{{ mitem.link }}{% endif %}" {% if not "#" in mitem.link  %}class="smoothscroll"{% endif %}>{{ mitem.text }}</a>
{% else %}
    {{ mitem.text }}
{% endif %}`

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 198 2 months ago
Themes & Styling · by Ian, 2 months ago
3 94 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 455 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 48 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 128 3 months ago