Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Syntax miskate of a subpage crashes twig template

Started by Tobias Scheinert 7 years ago · 0 replies · 886 views
7 years ago

Hi,

today I had the case that a user made a Markdown syntax mistake in one of the news sub pages. This caused the complete news site to crash because the "childPage.summary(250)" statement tried to get the first 250 characters from the broken sub page.

TWIG
{% for childPage in page.children.visible %}
  <div>
    <h2><a href="{{ childPage.url }}">{{ childPage.title }}</a></h2>
    <p>{{ childPage.summary(250) }}</p>
    <p><a class="btn btn-secondary" href="{{ childPage.url }}" role="button">More &raquo;</a></p>
  </div>
  <hr />
{% endfor %}

This resulted in following error message:

grav.CRITICAL: An exception has been thrown during the rendering of a template ("Malformed URL: http://").

The reason was the malformed url as stated in the error message.

My question is: Is there any way to prevent this? Something like ahh okay this sub page is broken, lets skip this one?

Best Regards
Tobias

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 1 year ago
6 1663 1 year ago
Content & Markdown · by Ton Haarmans, 2 years ago
10 1235 2 years ago
Content & Markdown · by Jan L'Am, 2 years ago
4 1099 2 years ago
Content & Markdown · by Leonardo, 2 years ago
3 1002 2 years ago
Content & Markdown · by belthasar, 2 years ago
4 1492 2 years ago