php, pdo, tpl and kendo

4 posts, 0 answers
  1. richard
    richard avatar
    48 posts
    Member since:
    Dec 2010

    Posted 02 May 2012 Link to this post

    well I can successfully use php, pdo and kendo together but when I try to put kendo web widgets into TPL I get a Smarty compile error on something that works perfectly well in a php file.

    should Kendo work in Smarty tpl files?

    thanks,
    Richard
  2. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 03 May 2012 Link to this post

    Hello,

    Is it possible for you to provide more information regarding the problem? A source code and the error message would allow us to provide better assistance. 

    All the best,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. richard
    richard avatar
    48 posts
    Member since:
    Dec 2010

    Posted 03 May 2012 Link to this post

    Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "modules\grid.tpl" on line 62 "columns: [{ field: &quot;FirstName&quot; }, { field: &quot;LastName&quot; }, {command: &quot;destroy&quot;}]," - Unexpected ": ", expected one of: "}" , " "' in C:\xampp\php\Smarty\sysplugins\smarty_internal_templatecompilerbase.php:627 Stack trace: #0 C:\xampp\php\Smarty\sysplugins\smarty_internal_templateparser.php(3154): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 C:\xampp\php\Smarty\sysplugins\smarty_internal_templateparser.php(3219): Smarty_Internal_Templateparser->yy_syntax_error(2, ': ') #2 C:\xampp\php\Smarty\sysplugins\smarty_internal_smartytemplatecompiler.php(105): Smarty_Internal_Templateparser->doParse(2, ': ') #3 C:\xampp\php\Smarty\sysplugins\smarty_internal_templatecompilerbase.php(171): Smarty_Internal_SmartyTemplateCompiler->doCompile('<!doCTYpe html>...') #4 C:\xampp\php\Smarty\sysplugins\smarty_internal_template.php(187): Smarty_Internal_TemplateCompile inC:\xampp\php\Smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 627

      $(function() {
       $("#grid").kendoGrid({
        dataSource: {
         transport: {
          read: "data/employees.php",

          update:
          {
           url: "data/employees.php",
           type: "POST"
          },                                             
          destroy:
          {
           url: "data/employeeDelete.php",
           type: "DELETE"
          },
          create:
          {
           url: "data/employees.php",
           type: "PUT"
          }
         },
         error: function(e) {
          alert(e.responseText);
         },
         schema: {
          data: "data",
          model: {
           id: "EmployeeID",
           fields: {
            FirstName: { validation: { required: true} },
            LastName: { validation: { required: true} }
           }
          }
         }
        },
        columns: [{ field: "FirstName" }, { field: "LastName" }, {command: "destroy"}],  <----------------------------- LINE 62
        toolbar: [ "save", "cancel", "create"],
        detailTemplate: kendo.template($("#template").html()),
                    detailInit: detailInit,
                    editable: true,
                    navigatable: true,
                    filterable: true,
        scrollable: true
       });


    As you can see this is from an example in the blog section using php. Works great as a php file but in the tpl Smarty does not like it. What I did find is that to get around the problem use the {literal} {/literal} Smarty tags to ignore code within the section.
  4. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 03 May 2012 Link to this post

    Hi,

    This seems like a general issue with Smarty and embedded JavaScript, described in their FAQ.

    http://smarty.incutio.com/?page=SmartyFrequentlyAskedQuestions  

    Search for 

    Q: Is there a way to escape '{' and '}' in html? 


    (they do not have anchors for the FAQ section). 

    All the best,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top