Salve a tutti
č un po' di tempo che non mi cimento con php e DB.
Vorrei fare in modo che in un modulo mi vengano riportati non i nomi degli stati o regioni ma le localitā.
Ho tentato a modificare qualcosa ma non so dove metter mano a sto punto.
Grazie

Questo il codice da modificare:

Codice PHP:
<?php defined('_JEXEC') or die('Restricted access'); // no direct access ?>
<?php 
jimport
'joomla.application.application' );
require_once( 
JPATH_SITE.DS.'components'.DS.'com_properties'.DS.'helpers'.DS.'link.php' );
$link LinkHelper::getLink('properties','showcountry','','','','',$item->slug,'','');
$x=0;
$cyidJRequest::getVar('cyid'0'''int');
$sid JRequest::getVar('sid'0'''int');
$lid JRequest::getVar('lid'0'''int');
?>
<ul class="menu">
<?php
if($OnlyShowStates)   
    {
    
        
    foreach (
$States as $State) { 
$linkState LinkHelper::getLink('properties','showstate','',$State->CYslug,$State->Sslug,'','','','');
$x++;  
if(
$sid == $State->id){$current='current active';$style_a='text-decoration:underline;color:#000000;';}else{$current='';$style_a='';}
$clase 'level1 item'.$x.' '.$current;   
    
?>  
  <li class="<?php echo $clase?>">    
    <a style=" <?php echo $style_a?> margin-left:0px; font-weight:bold;" class="<?php echo $clase?>" href="       
      <?php echo $linkState?> ">       
      <span>        
        <?php echo $State->name.'('.$State->tot.')'?>      
      </span></a>  
    
<?php  
if($sid == $State->id){
foreach (
$Localities as $Locality) { 
$linkLocality LinkHelper::getLink('properties','showlocality','',$State->CYslug,$State->Sslug,$Locality->Lslug,'','','');
$x++;    
if(
$lid == $Locality->id){$current='current active';$style_a='text-decoration:underline;color:#000000;';}else{$current='';$style_a='';}
$clase 'level1 item'.$x.' '.$current;
    
?>   
  <li class="<?php echo $clase?>" style="margin-left:10px;">    
    <a style=" <?php echo $style_a?>" class="<?php echo $clase?>" href="       
      <?php echo $linkLocality?> ">       
      <span>        
        <?php echo $Locality->name.'('.$Locality->tot.')'?>      
      </span></a>  
    
  <?php //end foreach states?>  
  <?php //end if states?>
<?php 
//end foreach Localities
    
    
//end $OnlyShowStates
    
    
    
else
    
    
    
    {
       
    foreach (
$Countries as $Country) { 
    
$linkCountry LinkHelper::getLink('properties','showcountry','',$Country->CYslug,'','','','','');
$x++;
if(
$cyid == $Country->id){$current='current active';$style_a='text-decoration:underline;color:#000000;';}else{$current='';$style_a='';}
$clase 'level1 item'.$x.' '.$current;
    
?>  
  <li class="<?php echo $clase?>">    
    <a style=" <?php echo $style_a?> margin-left:0px; font-weight:bold;" class="<?php echo $clase?>" href="       
      <?php echo $linkCountry?> ">       
      <span>        
        <?php echo $Country->name.'('.$Country->tot.')'?>      
      </span></a>  
  
<?php
if($cyid == $Country->id){
    
    
    
    
    
    foreach (
$States as $State) { 
$linkState LinkHelper::getLink('properties','showstate','',$Country->CYslug,$State->Sslug,'','','','');
$x++; 
if(
$sid == $State->id){$current='current active';$style_a='text-decoration:underline;color:#000000;';}else{$current='';$style_a='';}
$clase 'level1 item'.$x.' '.$current;
    
?>  
  <li class="<?php echo $clase?>" style="margin-left:10px;">    
    <a style=" <?php echo $style_a?> margin-left:0px; font-weight:bold;" class="<?php echo $clase?>" href="       
      <?php echo $linkState?> ">       
      <span>        
        <?php echo $State->name.'('.$State->tot.')'?>      
      </span></a>  
  
<?php  
if($sid == $State->id){
foreach (
$Localities as $Locality) { 
$linkLocality LinkHelper::getLink('properties','showlocality','',$Country->CYslug,$State->Sslug,$Locality->Lslug,'','','');
$x++; 
if(
$lid == $Locality->id){$current='current active';$style_a='text-decoration:underline;color:#000000;';}else{$current='';$style_a='';}
$clase 'level1 item'.$x.' '.$current;
    
?>  
  <li class="<?php echo $clase?>" style="margin-left:20px;">       
    <a style=" <?php echo $style_a?>" class="<?php echo $clase?>" href="            
      <?php echo $linkLocality?>  ">            
      <span>               
        <?php echo $Locality->name.'('.$Locality->tot.')'?>            
      </span></a>  
    
  <?php //end foreach states?>  
  <?php //end if states?>
<?php 
//end foreach Localities

}     
}
    
?>[/list]

Codice PHP:
<?php
defined
('_JEXEC') or die('Direct Access to this location is not allowed.'); 
class 
Modprop_locationHelper 
{
    function 
getCountries()
    {
    global 
$mainframe$option;     
    
$db = &JFactory::getDBO();
        
$query 'SELECT c.*,count(p.id) as tot, '
                   
' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as CYslug '
                
' FROM #__properties_country as c '
                   
' left join #__properties_products as p on p.cyid = c.id '
                
' WHERE c.published = 1 AND p.published = 1'
                
' group by c.id ORDER BY c.name';
                                                    
        
$db->setQuery($query);
        
        
$items $db->loadObjectList();        
        
//$items = ($items = $db->loadObjectList())?$items:array(); 
        
return $items;
    }
    
    
function 
getStates($cyid)
    {
        global 
$mainframe$option;  
        
//$cyid = JRequest::getVar('cyid', 0, '', 'int'); 
    
jimport('joomla.application.component.helper');
    
$db = &JFactory::getDBO();
       
$query 'SELECT s.*,count(p.id) as tot, '
                   
' CASE WHEN CHAR_LENGTH(cy.alias) THEN CONCAT_WS(":", cy.id, cy.alias) ELSE cy.id END as CYslug, '
                
' CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(":", s.id, s.alias) ELSE s.id END as Sslug '
                
' FROM #__properties_state as s '
                
' left join #__properties_products as p on p.sid = s.id '
                
' left join #__properties_country as cy on cy.id = p.cyid '
                   
                
' WHERE s.published = 1 AND p.published = 1 AND s.parent = '.$cyid
                
' group by s.id ORDER BY s.name';
                                                    
        
$db->setQuery($query);
        
$States $db->loadObjectList();        
       
// echo str_replace('#_','jos',$query);
        
return $States;
    }
function 
getLocalities()
    {            
        
$db = &JFactory::getDBO();    
$sid JRequest::getVar('sid'0'''int');
                
$query 'SELECT l.*,count(p.id) as tot, '
                
' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(":", l.id, l.alias) ELSE l.id END as Lslug '
                
' FROM #__properties_locality as l '
                   
' left join #__properties_products as p on p.lid = l.id '
                
' WHERE l.published = 1 AND p.published = 1 AND l.parent = '.$sid
                
' group by l.id ORDER BY l.name';
                
        
$db->setQuery($query);        
        
$Localities $db->loadObjectList();      
        return 
$Localities;
    }
        
        
        
        function 
getLocalitiesByCountry()
    {            
        
$db = &JFactory::getDBO();    
$cyid JRequest::getVar('cyid'0'''int'); 
                
$query 'SELECT l.*,count(p.id) as tot, '
                
' CASE WHEN CHAR_LENGTH(s.alias) THEN CONCAT_WS(":", s.id, s.alias) ELSE s.id END as Sslug, '
                
' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(":", l.id, l.alias) ELSE l.id END as Lslug '
                
' FROM #__properties_locality as l '
                
' LEFT JOIN #__properties_state AS s ON s.id = l.parent '
                   
' left join #__properties_products as p on p.lid = l.id '
                
' WHERE l.published = 1 AND p.published = 1 AND s.parent = '.$cyid
                
' group by l.id ORDER BY l.name';
//echo str_replace('#_','jos',$query);                
        
$db->setQuery($query);        
        
$Localities $db->loadObjectList();      
        return 
$Localities;
    }
    
    
}