[Resolvido] loop:i PHP, separar resultado por categoria
Bom Dia Galera
Estou mexendo em sistema para imóveis, me viro com SELECT, INSERT, UPDATE, mas nesse código tem uma tag no HTML
<!--{loop:i}-->
que já entendi ser um pedaço do php que está em outra página. O que eu não estou conseguindo fazer é filtrar da seguinte forma, quando o cara abre a página, gostaria que aparecesse 12 imóveis destaque venda e depois 12 imóveis destaque aluguel, OS imóveis venda aparecem de boa, mas os de aluguel não. alguém poderia me da uma força? fico grato. code abaixo.
<!--{loop:i}-->
<!--{<div class="col-xs-12 col-sm-10 col-lg-3 col-md-3">}-->
<!--{<div class="item-box">}-->
<!--{<p style="background-color:#272f57;font-weight:bold; padding:5px; color:#fff;">i.tipo_title <span class="pull-right label label-danger">Ref.: i.item_ref</span></p> }-->
<!--{<p><span class="pull-left ribbon">i.item_promo</span></p>}-->
<!--{<a href="[baseUri]/imovel/i.categoria_url/i.sub_url/i.item_id/">}-->
<!--{<img class="img-responsive" src="[baseUri]/thumb/i.foto_url/336/200/crop/" width="336" height="200" title="i.tipo_title em i.sub_title - i.categoria_title por i.item_preco"/>}-->
<!--{</a>}-->
<!--{<p><strong>i.categoria_title - i.sub_title</strong></p>}-->
<!--{}-->
<!--{<p class="border-bottom item-box-sprite text-center">}-->
<!--{<span class="dorm">i.item_dorm</span> }-->
<!--{<span class="wc">i.item_wc</span> }-->
<!--{<span class="vaga">i.item_vaga</span> }-->
<!--{<span class="area">i.item_area M²</span>}-->
<!--{</p>}-->
<!--{}-->
<!--{<h4 style="background-color:#272f57;font-weight:bold; padding:5px; color:#fff;><strong> <span class="pull-left">R$ i.item_preco</span><span class="pull-right"> i.item_finalidade</span></strong></h4>}-->
<!--{<br />}-->
<!--{</div>}-->
<!--{</div>}-->
<!--{end:i}-->
public function welcome()
{
$this->tpl( 'public/index.html' );
$this->select()
->from( 'item')
->join( 'tipo', 'item_tipo = tipo_id', 'INNER' )
->join( 'sub', 'item_sub = sub_id', 'INNER' )
->join( 'categoria', 'sub_categoria = categoria_id', 'INNER' )
->join( 'foto', 'foto_item = item_id and foto.foto_pos = ( SELECT MIN( foto_pos ) FROM foto where foto_item = item_id)', 'LEFT' )
->where( 'item_show = 1 and item_destaque = 1 and item_finalidade = 1' )
->paginate( 12 )
->groupby( 'item_id' )
->orderby( 'item_pos asc' )
->execute();
if ( $this->result() )
{
$aux = $this->data;
$keys = '';
$content = '';
$cities = array( );
foreach ( $aux as $k => $v )
{
if ( $aux[$k]['item_finalidade'] == 2 )
{
if ( $aux[$k]['item_preco_locacao'] >= 1 )
{
$aux[$k]['item_preco'] = $aux[$k]['item_preco_locacao'];
}
else
{
$aux[$k]['item_preco'] = 'Consulte-nos';
}
}
elseif ( $aux[$k]['item_finalidade'] == 3 )
{
if ( $aux[$k]['item_preco_locacao'] >= 1 )
{
$aux[$k]['item_preco'] = $aux[$k]['item_preco_locacao'];
}
}
elseif ( $aux[$k]['item_finalidade'] == 4 )
{
if ( $aux[$k]['item_preco_temp'] >= 1 )
{
$aux[$k]['item_preco'] = $aux[$k]['item_preco_temp'];
}
}
if ( $aux[$k]['item_preco'] == '0,00' || $aux[$k]['item_preco'] < 1 )
{
$aux[$k]['item_preco'] = 'Consulte-nos';
}
else
{
$aux[$k]['item_preco'] = number_format( $aux[$k]['item_preco'], 2, ',', '.' );
}
if ( $aux[$k]['item_area'] == 0 )
{
$aux[$k]['item_area'] = "";
$aux[$k]['item_ar_visible'] = "hider";
}
if ( $aux[$k]['item_vaga'] == 0 )
{
$aux[$k]['item_vaga'] = "";
$aux[$k]['item_vg_visible'] = "hider";
}
if ( $aux[$k]['item_dorm'] == 0 )
{
$aux[$k]['item_dorm'] = "";
$aux[$k]['item_dm_visible'] = "hider";
}
if ( $aux[$k]['item_vaga'] == 0 )
{
$aux[$k]['item_vaga'] = "0";
}
if ( $aux[$k]['item_wc'] == 0 )
{
$aux[$k]['item_wc'] = "0";
}
if ( $aux[$k]['item_dorm'] == 0 )
{
$aux[$k]['item_dorm'] = "0";
}
if ( !isset( $aux[$k]['foto_url'] ) || $aux[$k]['foto_url'] == "" )
{
$aux[$k]['foto_url'] = "empty";
}
if ( isset( $aux[$k]['item_vendido'] ) )
{
if ( $aux[$k]['item_vendido'] <= 9 )
{
$pat = array( '/0/', '/1/', '/2/', '/3/', '/4/', '/5/', '/6/', '/7/', '/8/', '/9/' );
$rep = array( '', 'Vendido', 'Alugado', 'Lançamento', 'Pronto para morar', 'Em construção', 'Oportunidade', 'Financie', 'Decorado', 'Para renda' );
}
else
{
$pat = array( '/10/', '/11/', '/12/' );
$rep = array( 'Alugue', 'Condomínio', 'Cobertura' );
}
$aux[$k]['item_vendido'] = preg_replace( $pat, $rep, $aux[$k]['item_vendido'] );
}
if ( $aux[$k]['sub_title'] == "." || $aux[$k]['sub_title'] == "" )
{
$aux[$k]['sub_title'] = "*";
$aux[$k]['sub_url'] = "bairro";
}
if ( $aux[$k]['item_dorm'] >= 1 )
{
$keys .= $aux[$k]['tipo_title'] . " com " . $aux[$k]['item_dorm'] . " dormitórios em " . $aux[$k]['categoria_title'] . ", ";
}
else
{
$keys .= $aux[$k]['tipo_title'] . " em " . $aux[$k]['categoria_title'] . ", ";
}
if ( !in_array( $aux[$k]['categoria_title'], $cities ) )
{
$cities[] = $aux[$k]['categoria_title'];
$content .= "imóveis em " . $aux[$k]['categoria_title'] . ", ";
}
}
$this->assign( 'content', $content );
$this->assign( 'keys', $keys );
$this->data = $aux;
$pat = array( '/1/', '/2/', '/3/', '/4/' );
$rep = array( 'Venda', 'Locação', 'Locação e Venda', 'Temporada' );
$this->preg( $pat, $rep, 'item_finalidade' );
if ( !isset( $this->uri_segment[2] ) )
{
$this->assign( 'categoria_active', 'hider' );
}
$this->encode( 'sub_title', 'ucwords' );
$this->addkey( 'item_promo', '', 'item_vendido' );
$this->preg( '/\.jpg/', '', 'foto_url' );
//$this->clonekey( 'item_dorm', array( 'item_suite', 'item_dorm' ), '+' );//soma suite + dorms
$this->fetch( 'i', $this->data );
}
$this->fillSlideShow();
$this->fillTipo();
$this->fillCategoria();
$this->render();
}Discussão (6)
Carregando comentários...