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.

Content & Markdown

Syntax miskate of a subpage crashes twig template

Started by Tobias Scheinert 6 years ago · 0 replies · 590 views
6 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, 8 months ago
6 100 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 187 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 63 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 259 1 year ago