1

I created a generic 404.html template to replace the default Craft page. I'm getting the following error when forcing a 404 in browser. Any idea what the issue is?

Twig_Error_Syntax

The filter "match" does not exist. Did you mean "batch" in "404" at line 4 (/Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php:573)

#0 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(437): Twig_ExpressionParser->getFilterNodeClass('match', 4)
#1 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(422): Twig_ExpressionParser->parseFilterExpressionRaw(Object(Twig_Node_Expression_GetAttr))
#2 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(287): Twig_ExpressionParser->parseFilterExpression(Object(Twig_Node_Expression_GetAttr))
#3 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(179): Twig_ExpressionParser->parsePostfixExpression(Object(Twig_Node_Expression_Name))
#4 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(84): Twig_ExpressionParser->parsePrimaryExpression()
#5 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/ExpressionParser.php(41): Twig_ExpressionParser->getPrimary()
#6 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/TokenParser/If.php(38): Twig_ExpressionParser->parseExpression()
#7 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Parser.php(187): Twig_TokenParser_If->parse(Object(Twig_Token))
#8 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Parser.php(95): Twig_Parser->subparse(NULL, false)
#9 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Environment.php(507): Twig_Parser->parse(Object(Twig_TokenStream))
#10 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Environment.php(559): Twig_Environment->parse(Object(Twig_TokenStream))
#11 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Environment.php(334): Twig_Environment->compileSource('{% extends "_la...', '404')
#12 /Applications/MAMP/htdocs/mysite.com/craft/app/vendor/twig/twig/lib/Twig/Environment.php(292): Twig_Environment->loadTemplate('404')
#13 /Applications/MAMP/htdocs/mysite.com/craft/app/services/TemplatesService.php(220): Twig_Environment->render('404', Array)
#14 /Applications/MAMP/htdocs/mysite.com/craft/app/controllers/BaseController.php(74): Craft\TemplatesService->render('404', Array)
#15 /Applications/MAMP/htdocs/mysite.com/craft/app/controllers/TemplatesController.php(190): Craft\BaseController->renderTemplate('404', Array)
#16 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/web/actions/CInlineAction.php(49): Craft\TemplatesController->actionRenderError()
#17 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#18 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#19 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#20 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/web/CWebApplication.php(282): CController->run('renderError')
#21 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/base/CErrorHandler.php(331): CWebApplication->runController('templates/rende...')
#22 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/base/CErrorHandler.php(204): CErrorHandler->render('error', Array)
#23 /Applications/MAMP/htdocs/mysite.com/craft/app/etc/errors/ErrorHandler.php(113): CErrorHandler->handleException(Object(Craft\HttpException))
#24 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/base/CErrorHandler.php(129): Craft\ErrorHandler->handleException(Object(Craft\HttpException))
#25 /Applications/MAMP/htdocs/mysite.com/craft/app/framework/base/CApplication.php(732): CErrorHandler->handle(Object(CExceptionEvent))
#26 [internal function]: CApplication->handleException(Object(Craft\HttpException))
#27 {main}

Template code causing issue:

{!-- META TITLE --}
<title>
    {% if entry.metaTitle != '' %}
        {{entry.metaTitle}}
    {% else %}
        My Site
    {% endif %}
</title>

{!-- META DESCRPTION --}
{% if entry.metaDescription != '' %}
<meta name="description" content="{{ entry.metaDescription }}">
{% endif %}

{!-- META KEYWORDS --}
{% if entry.metaKeywords != '' %}
    <meta name="keywords" content="{{ entry.metaKeywords }}">
{% endif %}

Here's my _layout.html:

{% include 'global/head.html' %}    

<body>
    <div class="side-push">
        <div id="wrapper">
            {% include 'global/header.html' %}  
                {% block home_slider %}
                {% endblock %}
                {% block content %}
                {% endblock %}
            {% include 'global/footer.html' %}      
        </div>
    </div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">window.jQuery || document.write('<script src="/js/jquery-1.11.1.min.js"><\/script>')</script>
    <script type="text/javascript" src="/js/jquery.main.js"></script>
</body>
</html>

header.html:

    <header id="header">
        <div class="header-top">
            <span class="slogan">Family Owned Since 1924</span>
            <div class="logo">
                <a href="{{ siteUrl }}">
                    <img src="/images/logo.png" alt="magoon signs">
                </a>
            </div>
        </div>
        <div class="main-nav">
            <a href="#" class="opener"><span>Menu</span></a>
            <nav id="nav">
                {# get menu items #}
                {% set pageItems = craft.entries.section('services').level('<= 2') %}
                {# % set pageItems = craft.entries.level('<= 2') %# }

                {# Output the sub menu #}
                <ul>
                    <li><a href="{{ siteUrl }}">Home</a></li>
                    {% set entry = craft.entries.slug('about').first %}
                    <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>

                    {% nav page in pageItems %}
                    <li>
                        <a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}">
                            {% if page.navigationTitle %}{{ page.navigationTitle|nl2br }}{% else %}{{ page.title }}{% endif %}
                        </a>
                        {% ifchildren %}
                        <div class="drop">
                            <ul>
                                {% children %}
                            </ul>
                        </div>
                        {% endifchildren %}
                    </li>
                    {% endnav %}
                </ul>
                <ul>
                    {% set entry = craft.entries.slug('testimonials').first %}
                        <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
                    {% set entry = craft.entries.slug('contact').first %}
                        <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
                    {% set entry = craft.entries.slug('get-a-quote').first %}
                        <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
                </ul>
            </nav>
        </div>
    </header>

footer.html:

    <footer id="footer">
        <div class="holder">
            <a href="#" class="badge">
                <img src="/images/img4.png" alt="image description">
            </a>
            <div class="wrap">
                <ul class="social-networks">
                    <li><a class="linkdin" href="#">linkedin</a></li>
                    <li><a class="facebook" href="#">facebook</a></li>
                </ul>
                <h2>{{ siteName }}</h2>
                <address>{{ companyInfo.address }}</address>
                <a class="tel-link" href="tel:{{ companyInfo.phoneNumberLink }}">{{ companyInfo.phoneNumber }}</a>
                <span class="timings">
                    Open: <time datetime="2014-08-21">Mon.-Fri. 8:30am-4pm</time> Closed Daily from <time datetime="2014-08-21">12:00pm-1:00pm</time>
                </span>
            </div>
        </div>
    </footer>

head.html:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 " />

    {!-- META TITLE --}
    <title>
        {% if entry.metaTitle != '' %}
            {{entry.metaTitle}}
        {% else %}
            My Site
        {% endif %}
    </title>

    {!-- META DESCRPTION --}
    {% if entry.metaDescription != '' %}
    <meta name="description" content="{{ entry.metaDescription }}">
    {% endif %}

    {!-- META KEYWORDS --}
    {% if entry.metaKeywords != '' %}
        <meta name="keywords" content="{{ entry.metaKeywords }}">
    {% endif %}

    <link href='http://fonts.googleapis.com/css?family=Vast+Shadow' rel='stylesheet' type='text/css'>
    <link media="all" rel="stylesheet" href="/css/all.css">
    <link rel="stylesheet" href="/css/flexslider.css" type="text/css">

    <!--[if lt IE 9]><script src="js/ie.js"></script><![endif]-->
    {% block css_wufoo %}{% endblock %}
    {% block css_fancybox %}{% endblock %}

</head>
1

The error indicates you're trying to use a Twig filter that doesn't exist in your 404 template at line 4.

Maybe you've got a plugin that added it's own filter, but you don't have the plugin installed or enabled?

Update:

Based on the follow up comments, the error message is very misleading and not sure where it is coming from. The 404 template doesn't have an entry variable defined, so the solution is to wrap any references to it in:

{% if entry is defined %}
    {{ entry.metaTitle }}
{% endif %}
| improve this answer | |
  • Thanks for the help, Brad. I think it's the entry tags causing issue. Any idea how to fix so that I can use those tags in head? I added code to original post for your reference. – frshjb373 Dec 8 '14 at 18:30
  • Is that code from your _layout.html template? – Brad Bell Dec 8 '14 at 18:37
  • Ya...I'm embedding the head in the _layout.html. Added to original post as well. – frshjb373 Dec 8 '14 at 18:38
  • Might as well post global/head, global/header and global/footer, too. :) – Brad Bell Dec 8 '14 at 18:55
  • Updated original post. – frshjb373 Dec 8 '14 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.