在osclass中,如何只显示带有广告的城市?
In osclass, how display cities only with ads?
如何只用广告显示地区和城市?为什么我看不到很多广告?我想使用 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
}
?>
城市的解决方案是:
<?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 } ?>
现在它已经过测试并适用于城市
这将列出所有城市及其项目数量。
区域 > 城市的解决方案是:
$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>';
}
谢谢!你的代码很好!我现在需要重写它以显示国家/地区。这是我的代码,但无法正常工作,此代码不再显示德国地区,而是再次显示奥地利地区:
<?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>';
}
}
} ?>
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>';
}
如何只用广告显示地区和城市?为什么我看不到很多广告?我想使用 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
}
?>
城市的解决方案是:
<?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 } ?>
现在它已经过测试并适用于城市 这将列出所有城市及其项目数量。
区域 > 城市的解决方案是:
$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>';
}
谢谢!你的代码很好!我现在需要重写它以显示国家/地区。这是我的代码,但无法正常工作,此代码不再显示德国地区,而是再次显示奥地利地区:
<?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>';
}
}
} ?>
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>';
}