Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Syntax miskate of a subpage crashes twig template

Started by Tobias Scheinert 7 years ago · 0 replies · 777 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, 12 months ago
6 1204 11 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 965 1 year ago
Content & Markdown · by Jan L'Am, 2 years ago
4 845 2 years ago
Content & Markdown · by Leonardo, 2 years ago
3 767 2 years ago
Content & Markdown · by belthasar, 2 years ago
4 1182 2 years ago