Welcome Guest, Not a member yet? Register   Sign In
My views are too complex, there is a way to avoid this?
#1

[eluser]Sinclair[/eluser]
Hi,

I'am new to codeigniter, and I I'am with some trouble in organizing code and I think my Views are too complex.

How can I do better than this?

Example View:
Code:
<?php

$prevCidade = '';
$primVezTab = '0';
$primVezHrl = '0';

foreach ($result as $row){

    if ($prevCidade != $row->n_cidade){
        
        if ($primVezTab != '0') {
            echo "</tr></table><br />";
        }
        
        if ($primVezHrl == '0') {
            echo "<br />";
            echo "&nbsp;&nbsp;&nbsp;<span class=\"style4\">$row->n_cidade</span><br /><br />";
            echo "<table><tr>";
            }
        else {
            echo "<hr size=\"1\" noshade />&nbsp;&nbsp;&nbsp;<span class=\"style4\">$row->n_cidade</span><br /><br />";
            echo "<table><tr>";
            }
            
        # Assignar novos valores as variaveis(dizer que já passaram por aqui uma vez)
        $primVezTab = '1';
        $primVezHrl = '1';
        # Assignar a zero a variável que vai fazer as quebras na tabelas
        $i = 0;
        
        } # End ($prevCidade != $row->n_cidade)    
        
    # Para fazer a quebra na tabela    
    if ($i >= 4)
    {
        echo "    </tr>
                    <tr>
                      <td height=\"15\">&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>";
        $i = 0;
    }
        
        
    echo "<td>&nbsp;</td>";
    echo "<td><A >id_anuncio \"><img >id_anuncio/$row->n_ficheiro\" title=\"$row->n_anuncio\" alt=\"$row->n_anuncio\" width=\"221\" height=\"306\" /></a></td>";
            
        # Assignar novo valor a' variavel
        $prevCidade = $row->n_cidade;
        # Incrementar 1 a' variavel
        $i = $i + 1;
        
            
    } # End foreach
echo "</tr></table><br />";
?&gt;

Can I see examples of views on the web, what will help me to do better code using MVC?

Sorry my bad english.

Best Regards,


Messages In This Thread
My views are too complex, there is a way to avoid this? - by El Forum - 01-17-2010, 01:54 PM
My views are too complex, there is a way to avoid this? - by El Forum - 01-17-2010, 02:48 PM
My views are too complex, there is a way to avoid this? - by El Forum - 01-17-2010, 04:06 PM
My views are too complex, there is a way to avoid this? - by El Forum - 01-17-2010, 04:19 PM
My views are too complex, there is a way to avoid this? - by El Forum - 01-18-2010, 06:06 AM
My views are too complex, there is a way to avoid this? - by El Forum - 01-18-2010, 11:10 AM
My views are too complex, there is a way to avoid this? - by El Forum - 01-18-2010, 11:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB