Invenzzia »

Pages: [1]   Go Down
  Print  
Author Topic: OPTv2: Main tpl parced but opt:include view not parce  (Read 1969 times)
Description: Main tpl is parced but the opt:include inside the main tpl not parced
0 Members and 2 Guests are viewing this topic.
amichelin
User

Offline Offline

Posts: 10


View Profile
« on: May 01, 2009, 14:58:45 »

Hi:
I get from manual this page : http://static.invenzzia.org/docs/opt/2_0/book/en/guide.views.html and use the same structure :

main.tpl
Code:
<?xml version="1.0" ?>
<opt:root>
<opt:prolog />
<opt:dtd template="xhtml10strict"/>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
<head>
    <title>{$title}</title>
    <meta http-equiv="Content-Encoding" content="gzip" />
    <!--meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" / -->
    <link rel="stylesheet" href="../themes/agenda.css" type="text/css" media="ALL" />
    <link rel="stylesheet" href="../themes/intranet.css" type="text/css" media="ALL" />
    <opt:selector name="css">
      <opt:extjs>
        <link rel="stylesheet" href="../js/ext/resources/css/ext-all.css" type="text/css" />
      </opt:extjs>
      <opt:printable>
        <link rel="stylesheet" href="../themes/impressao.css" type="text/css" media="print"/>
      </opt:printable>
    </opt:selector>
    <script type="text/javascript" src="../js/commonfunctions.js"></script>
    <opt:selector name="js">
        <opt:extjs>
            <script type="text/javascript" src="../js/ext/adapter/ext/ext-base.js"></script>
            <script type="text/javascript" src="../js/ext/ext-all.js"></script>
            <script type="text/javascript" src="../js/ext/build/locale/ext-lang-pt_br-min.js"></script>
        </opt:extjs>
        <opt:printable><script type="text/javascript" src="../js/impressao.js"></script></opt:printable>
        <opt:efeitos><script type="text/javascript" src="../js/efeitos.js"></script></opt:efeitos>
    </opt:selector>
</head>
<body class="BodyProbrax">
-- This is not workig, only shows the mesage.
    <opt:include view="$module">
                <p>We are sorry, but we are unable to load the template.</p>
    </opt:include>
</body>
</html>
</opt:root>

formgrupo.tpl
Code:
<?xml version="1.0" ?>
<opt:root>
    <div style=" text-align: center; margin: 20px 0px 0px 0px; padding: 0px; ">
        <div class="Borda" style=" margin: auto; padding: 10px 5px 10px 5px; width: 500px; height: 110px; ">
            <form method="post" action="formgrupos.php?idgrupo=>{$grupos.id}" onsubmit="return Valid();">
                <table border="0" width="100%" cellspacing="1">
                    <caption class="TituloForm">Cadastro de Grupos (Familias)</caption>
                    <tr>
                        <td align="right" width="30%" class="Etiqueta1">Descrição :</td>
                        <td  align="left" width="70%">
                            <input name="txtdescricao" type="text" value="{$grupos.descricao}" style=" width: 220px; " />
                        </td>
                     </tr>
                     <tr>
                        <td class="Etiqueta1R">Abreviação :</td>
                        <td class="Etiqueta2L">
                            <input name="txtabreviacao" type="text" value="{$grupos.abreviacao}" style=" width: 220px; " />
                        </td>
                     </tr>
                </table>

                <div style=" text-align: center; margin-top: 10px; "><input name="cmdgravar" type="submit" value="" class="BtnAceitar" /></div>
            </form>
        </div>

        <div class="Borda" style=" margin: 10px auto auto auto; width:60%; height: 295px; overflow: auto; ">
            <table style=" width: 97%; " cellspacing="1">
                <tr class="ColorTablaImPar2">
                    <td width="12%" class="TituloCtaConC">Código</td>
                    <td width="56%" class="TituloCtaConL" style=" padding-left: 60px; ">Descrição</td>
                    <td width="22%" class="TituloCtaConC" style=" padding-left: 30px; ">Abreviação</td>
                    <td width="5%"  class="TituloCtaConC"></td>
                    <td width="5%"  class="TituloCtaConC"></td>
                </tr>
                <opt:section name="gruposlist">
                <tr onmouseover="setPOver(this);" onmouseout="setPOut(this);">
                    <td class="TabelaC">{$gruposlist.pedido}</td>
                    <td class="TabelaL" style=" padding-left: 10px; ">{$gruposlist.descricao}</td>
                    <td class="TabelaL" style=" padding-left: 10px; ">{$gruposlist.abreviacao}</td>
                    <td class="TabelaC"><img src="../images/ico_editar.png" alt="Editar" onclick="JavaScript: self.location.href='formgrupos.php?idgrupo={$gruposlist.idgrupo}'; " /></td>
                    <td class="TabelaC">
                        <a href="formgrupos.php?idgrupo={$gruposlist.idgrupo}&elimino=1" onclick="JavaScript: return confirm('Deseja Eliminar a Grupo {$gruposlist.descricao} ?')"><img src="../images/ico_eliminar.gif" alt="Eliminar" /></a>
                    </td>
               </tr>
               <opt:sectionelse>
               <tr onmouseover="setPOver(this);" onmouseout="setPOut(this);"><td class="TabelaC" colspan="5">sem dados na consulta</td>
               </opt:sectionelse>
               </opt:section>
            </table>
        </div>
    </div>
</opt:root>

php code
Code:


$tpl = new Opt_Class;

$tpl->compile = '../util/opt/templates_c/';

// Loading from array
$tpl->sourceDir = array(
  'def' => $_SESSION['main_dir'] . 'comun/tpl', // the default directory
  'cm' => $_SESSION['main_dir'] . 'comercial/tpl'  // module folder
);

$tpl->setup();

$moduleView = new Opt_View('cm:grupos.tpl');

$moduleView->id = $_REQUEST['idgrupo']; // table id

// load from db
if ( $_REQUEST['idgrupo'] > 0 )
{
    $oGrupo = Doctrine::getTable('Grupos')->find($_REQUEST['idgrupo']);

    $moduleView->descricao  = $oGrupo->descricao;
    $moduleView->abreviacao = $oGrupo->abreviacao;
}

// seccion list data from db
$moduleView->gruposlist = MostroGrupos(); return s and array with data or an empty array.

$layoutView = new Opt_View('def:main.tpl');
$layoutView->title  = 'Cadastro de Grupos';
$layoutView->css    = array(); // Adicional css
$layoutView->js     = array(); // Adicional js
$layoutView->module = $moduleView; // add view to main.tpl

$output = new Opt_Output_Http;
$output->setContentType(Opt_Output_Http::XHTML, 'iso-8859-1');
$output->render($layoutView);



This only shows :  <p>We are sorry, but we are unable to load the template.</p>

What is brong, my code is brong or i missing some details?

Thanks in advance

Logged
Zyx
Your programmer
Administrator
User
*****
Offline Offline

Posts: 291



View Profile WWW
« Reply #1 on: May 01, 2009, 15:45:14 »

Perhaps you have used the wrong template file name. You say that your template is called formgrupo.tpl, but in the line below you request grupos.tpl:

Code:
$moduleView = new Opt_View('cm:grupos.tpl');

OPT shows this message if it cannot find the requested template (for example because of the invalid name or various problems with the directory path).

BTW. Small hint. I see in your template the lines like this:

Code:
<input name="txtabreviacao" type="text" value="{$grupos.abreviacao}" style=" width: 220px; " />

Unless you work in the quirks mode, this is an invalid construction. To read the value of the attribute from a variable, you must write:

Code:
<input name="txtabreviacao" type="text" parse:value="$grupos.abreviacao" style=" width: 220px; " />

Simply: you change the namespace to "parse" and write the expression without curly braces. Another, more complex example:

Code:
<!-- wrong -->
<a href="formgrupos.php?idgrupo={$gruposlist.idgrupo}&elimino=1" onclick="JavaScript: return confirm('Deseja Eliminar a Grupo {$gruposlist.descricao} ?')">

<!-- good -->
<a parse:href="'formgrupos.php?idgrupo='~$gruposlist.idgrupo~'&elimino=1'" parse:onclick="'JavaScript: return confirm(\'Deseja Eliminar a Grupo '~$gruposlist.descricao~' ?\')'">

~ is a string concatenation operator (the same role as dot in PHP)
Logged

PozDrX, Zyx
---Invenzzia group---
amichelin
User

Offline Offline

Posts: 10


View Profile
« Reply #2 on: May 02, 2009, 13:30:19 »

At this time i has only one error :

The opt says that prefix  formgrupo has no namespace.

Posição: http://localhost/homeinf/comercial/formgrupos.php
Line numbera 2, col 807:

Is the <form line. When i delete from tpl this $formgrupo.id the error move to the other parce.

Code:
<form method="post" parce:action="formgrupos.php?idgrupo=$formgrupo.id" onsubmit="return Valid();">
    <table border="0" width="100%" cellspacing="1">
       <caption class="TituloForm">Cadastro de Grupos (Familias)</caption>
       <tr>
           <td align="right" width="30%" class="Etiqueta1">Descrição :</td>
           <td  align="left" width="70%">
               <input name="txtdescricao" type="text" parce:value="$formgrupo.descricao" style=" width: 220px; " />
           </td>
       </tr>
       <tr>
           <td class="Etiqueta1R">Abreviação :</td>
           <td class="Etiqueta2L">
                 <input name="txtabreviacao" type="text" parce:value="$formgrupo.abreviacao" style=" width: 220px; " />
           </td>
       </tr>
    </table>

<div style=" text-align: center; margin-top: 10px; "><input name="cmdgravar" type="submit" value="" class="BtnAceitar" /></div>
</form>

Code:
$moduleView->id = $_REQUEST['idgrupo'];

if ( $_REQUEST['idgrupo'] > 0 )
{
    $oGrupo = Doctrine::getTable('Grupos')->find($_REQUEST['idgrupo']);

    $moduleView->descricao  = $oGrupo->descricao;
    $moduleView->abreviacao = $oGrupo->abreviacao;
}


how to make the parce in the form action, and i the input fields ?

The list off data  is ok.

Thanks in advance
Logged
eXtreme
Invenzzia
Administrator
User
*****
Offline Offline

Posts: 129

Jacek Jędrzejewski


View Profile WWW
« Reply #3 on: May 02, 2009, 17:39:22 »

parSe, not parce! SSSS not CCCC :P This is the first thing. The second, is that you join string and variable incorrectly. Check the manual or wiki page: http://wiki.invenzzia.org/wiki/String_concatenation_in_OPT about string concatenation, especially with "parse" namespace.
Logged

amichelin
User

Offline Offline

Posts: 10


View Profile
« Reply #4 on: May 02, 2009, 22:15:10 »

At this time the variable are resolved but the value is not put in the html .

This code

Code:

$moduleView->id = 123;
$moduleView->abreviacao = 'asasasasaa';



The tpl
Code:
            <form method="post" parse:action="'formgrupos.php?idgrupo='~$formgrupo.id" onsubmit="return Valid();">
                <table border="0" width="100%" cellspacing="1">
                    <caption class="TituloForm">Cadastro de Grupos (Familias)</caption>
                    <tr>
                        <td align="right" width="30%" class="Etiqueta1">Descrição :</td>
                        <td  align="left" width="70%">
                            <input name="txtdescricao" type="text" parse:value="$formgrupo.descricao" style=" width: 220px; " />
                        </td>
                     </tr>
                     <tr>
                        <td class="Etiqueta1R">Abreviação :</td>
                        <td class="Etiqueta2L">
                            <input name="txtabreviacao" type="text" parse:value="$formgrupo.abreviacao" style=" width: 220px; " />
                        </td>
                     </tr>
                </table>

                <div style=" text-align: center; margin-top: 10px; "><input name="cmdgravar" type="submit" value="" class="BtnAceitar" /></div>
            </form>




What is brong wiht the code?
Logged
eXtreme
Invenzzia
Administrator
User
*****
Offline Offline

Posts: 129

Jacek Jędrzejewski


View Profile WWW
« Reply #5 on: May 03, 2009, 16:03:37 »

I don't understand how you use it.

You set variables here:
Code:
$moduleView->id = 123;
$moduleView->abreviacao = 'asasasasaa';

SO: they will be visible in your code as $id and $abreviacao! without any prefix of $formgrupo or any else (where did you get that from?)

Your final code should look like this:
Code:
            <form method="post" parse:action="'formgrupos.php?idgrupo='~$id" onsubmit="return Valid();">
                <table border="0" width="100%" cellspacing="1">
                    <caption class="TituloForm">Cadastro de Grupos (Familias)</caption>
                    <tr>
                        <td align="right" width="30%" class="Etiqueta1">Descrição :</td>
                        <td  align="left" width="70%">
                            <input name="txtdescricao" type="text" parse:value="$descricao" style=" width: 220px; " />
                        </td>
                     </tr>
                     <tr>
                        <td class="Etiqueta1R">Abreviação :</td>
                        <td class="Etiqueta2L">
                            <input name="txtabreviacao" type="text" parse:value="$abreviacao" style=" width: 220px; " />
                        </td>
                     </tr>
                </table>

                <div style=" text-align: center; margin-top: 10px; "><input name="cmdgravar" type="submit" value="" class="BtnAceitar" /></div>
            </form>
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: