如何仅使用广告显示区域及其城市?为什么我看不到广告的数量?我想使用jQuery,但我不知道如何。
<?php
$aRegions = Region::newInstance()->getByCountry('AT');
if(count($aRegions) > 0 ) { ?>
<ul>
<?php
foreach($aRegions as $region) {
//print_r ($region);
echo "<li>";
//$region['pk_i_id'].
?>
<div class="accordionButton">
<a href="javascript:void()">
<?php echo $region['s_name']."\n"; ?>
</a>
<?php // echo "</em>(". $region['items'].")</em>";?>
</div>
<?php
$aCities = City::newInstance()-> getByRegion($region['pk_i_id']);
if(count($aCities) > 0 ) {
echo "<div class=\"accordionContent\">";
echo "<ul>";
foreach($aCities as $city) {
// print_r ($city);
//$city["pk_i_id"].'
echo "<li>";
echo "<a href='". osc_search_url( array( 'sRegion'=>$region["s_name"], 'sCity' => $city['s_name'] ) ) ."'> ";
echo $city["s_name"]."\n";
echo "</em>(". $city['items'].")</em>";
echo "</a>";
echo "</li>";
}
}
echo "</ul>";
echo "</li>";
} ?>
</ul>
<?php
}
?>
答案 0 :(得分:1)
城市的解决方案是:
<?php if(osc_count_list_cities() > 0 ) { ?>
<ul>
<?php while(osc_has_list_cities() ) { ?>
<li><a href="<?php echo osc_list_city_url(); ?>"><?php echo osc_list_city_name() ; ?> <em>(<?php echo osc_list_city_items() ; ?>)</em></a></li>
<?php } ?>
</ul>
<?php } ?>
现在它经过测试并适用于城市 这将列出所有城市及其项目数。
答案 1 :(得分:0)
区域解决方案&gt;城市是:
$locations = array();
if(osc_count_list_cities() > 0 ) {
while(osc_has_list_cities() ) {
$city_id = osc_list_city_id();
$city = City::newInstance()->findByPrimaryKey($city_id);
$region_id = $city['fk_i_region_id'];
$locations[$region_id][$city_id] = array("cityurl"=>osc_list_city_url(), "cityname"=>osc_list_city_name(), "cityitems"=>osc_list_city_items());
}
echo '<ul>';
while(osc_has_list_regions() ) {
$region_id = osc_list_region_id();
echo '<li><a href="' . osc_list_region_url() . '">' . osc_list_region_name() . '<em>(' . osc_list_region_items() . ')</em></a>' ;
echo '<ul>';
foreach($locations[$region_id] as $acity) {
echo '<li><a href="' . $acity['cityurl'] . '">' . $acity['cityname'] . '<em>(' . $acity['cityitems'] . ')</em></a></li>' ;
}
echo '</ul></li><br/>';
}
echo '</ul>';
}
答案 2 :(得分:0)
谢谢!你的代码很好!我现在需要重写它以进行国家显示。这是我的代码,但无法正常工作,而不是显示德国地区,此代码再次显示奥地利地区:
<?php
$locations = array();
if(osc_count_list_cities() > 0 ) {
while(osc_has_list_cities() ) {
$city_id = osc_list_city_id();
$city = City::newInstance()->findByPrimaryKey($city_id);
$region_id = $city['fk_i_region_id'];
$locations[$region_id][$city_id] = array("cityurl"=>osc_list_city_url(), "cityname"=>osc_list_city_name(), "cityitems"=>osc_list_city_items());
}
?>
<ul>
<?php while(osc_has_countries() ) { ?>
<li><a href="<?php echo osc_country_url( array( 'sCountry' => osc_list_country_code() ) ) ; ?>"><?php echo osc_country_name() ; ?> <em>(<?php echo osc_country_items() ; ?>)</em></a>
<?php if (osc_country_name() =='Austria') { ?>
<?php
echo '<ul>';
while(osc_has_list_regions('AT') ) {
$region_id = osc_list_region_id();
echo '<li><a href="' . osc_list_region_url() . '">' . osc_list_region_name() . '<em>(' . osc_list_region_items() . ')</em></a>' ;
echo '<ul>';
foreach($locations[$region_id] as $acity) {
echo '<li><a href="' . $acity['cityurl'] . '">' . $acity['cityname'] . '<em>(' . $acity['cityitems'] . ')</em></a></li>' ;
}
echo '</ul></li><br/>';
}
echo '</ul>';
}
if (osc_country_name() =='Germany') { ?>
<?php
echo '<ul>';
while(osc_has_list_regions('DE') ) {
$region_id = osc_list_region_id();
echo '<li><a href="' . osc_list_region_url() . '">' . osc_list_region_name() . '<em>(' . osc_list_region_items() . ')</em></a>' ;
echo '<ul>';
foreach($locations[$region_id] as $acity) {
echo '<li><a href="' . $acity['cityurl'] . '">' . $acity['cityname'] . '<em>(' . $acity['cityitems'] . ')</em></a></li>' ;
}
echo '</ul></li><br/>';
}
echo '</ul>';
}
}
} ?>
答案 3 :(得分:0)
COUNTRIES的解决方案&gt;地区&gt; Osclass 3.7.x中的城市是
$locations = array();
if(osc_count_list_cities() > 0 ) {
while(osc_has_list_cities() ) {
$city_id = osc_list_city_id();
$city = City::newInstance()->findByPrimaryKey($city_id);
$region_id = $city['fk_i_region_id'];
$country_code = strtolower($city['fk_c_country_code']);
$locations[$country_code][$region_id][$city_id] = array("cityurl"=>osc_list_city_url(), "cityname"=>osc_list_city_name(), "cityitems"=>osc_list_city_items());
}
$locationsRegions = array();
while(osc_has_list_regions() ) {
$region_id = osc_list_region_id();
$region = Region::newInstance()->findByPrimaryKey($region_id);
$country_code = strtolower($region['fk_c_country_code']);
$locationsRegions[$country_code][$region_id] = array("regionurl"=>osc_list_region_url(), "regionname"=>osc_list_region_name(), "regionitems"=>osc_list_region_items());
}
echo "<ul>";
while(osc_has_list_countries() ) {
$country_code = strtolower(osc_list_country_code());
echo '<li><a href="' . osc_list_country_url() . '">' . osc_list_country_name() . '<em>(' . osc_list_country_items() . ')</em></a>' ;
echo '<ul>';
foreach($locationsRegions[$country_code] as $regionId => $aregion) {
echo '<li>';
echo '<a href="' . $aregion['regionurl'] . '">' . $aregion['regionname'] . '<em>(' . $aregion['regionitems'] . ')</em></a></br>' ;
echo '<ul>';
foreach($locations[$country_code][$regionId] as $acity) {
echo '<li><a href="' . $acity['cityurl'] . '">' . $acity['cityname'] . '<em>(' . $acity['cityitems'] . ')</em></a></li>' ;
}
echo '</ul></li><br/>';
}
echo '</ul></li><br/>';
}
echo '</ul>';
}