ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Parsing error (but no error in php)

September 12, 2012 12:13pm

Subscribe [1]
  • #1 / Sep 12, 2012 12:13pm

    gents agency

    16 posts

    Hi,

    I’m using php in this template. And I’m getting the Parsing error. So this is part of the code:

    1<?php
    2    $entries = array();
    3    {exp:channel:entries channel="locatie" disable="categories|category_fields|member_data|pagination" dynamic="yes" limit="1" }
    4        $entries['titel'] = '{locatie_naam_{language_code}}';
    5        {exp:playa:children channel="locatie_categorie" field="categorie" status="open" }
    6            $entries['categorie']['subcategorie'][{entry_id}]['titel'] = "{cat_naam_{language_code}}";
    7            {embed="api/hoofd" eid="{entry_id}"}
    8        {/exp:playa:children}
    9    {/exp:channel:entries}
    10
    11   header('Content-type: application/json');
    12   echo json_encode($entries);
    13?>

    I’m embedding a second template:

    1{exp:playa:children channel="locatie_categorie" field="cat_parent" entry_id="{embed:eid}" status="Hoofdcategorie" }
    2    if(empty($entries['categorie']['hoofdcategorie'][{entry_id}])){
    3        $entries['categorie']['hoofdcategorie'][{entry_id}]['titel'] = "{cat_naam_{language_code}}";
    4    }
    5{/exp:playa:children}

    PHP Parsing was set to occur after rendering of the template tags.

    This is one of many templates like that, but the only one with embedding another template.
    The error occurs on line 7.

    So I disabled the PHP Parsing to have a look at the source code. And it looks like this:

    1<?php
    2    $entries = array();
    3    {exp:channel:entries channel="locatie" disable="categories|category_fields|member_data|pagination" dynamic="yes" limit="1" }
    4        $entries['titel'] =  "test titel";
    5        
    6            $entries['categorie']['subcategorie'][{entry_id}]['titel'] = "bezienswaardigheden";
    7            if(empty($entries['categorie']['hoofdcategorie'][2])){
    8                $entries['categorie']['hoofdcategorie'][2]['titel'] = "visit heritage";
    9            }
    10…

    That looked ok. But why, did EE throw an error?
    So I copy pasted the PHP into a php file and tried it on the server. It gave no error…

    Does anyone know what the problem could be?

  • #2 / Sep 14, 2012 2:46pm

    Dan Decker

    7338 posts

    Hi gents agency,

    You need to enable PHP parsing and include the <?php ?> in the embedded template as well.

    Embedded templates do not inherit the properties of the template calls them.

    If you check the PHP setting and use PHP tags in the embedded template, do the error go away?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases