Loading


Advertisement:

Author Topic: If is location city home ? - ( get region name ? )  (Read 260 times)

altavista

  • Jr. Member
  • **
  • Posts: 71
If is location city home ? - ( get region name ? )
« on: March 17, 2017, 06:57:17 pm »
I've started playing with the osclass code, and it's very easy but I still need more juice, for example. My site is a subdomain city based, so in my header i have this :

Code: [Select]
<title> <? if (osc_is_home_page()) echo ucwords(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST])); ?>[b] <? if (osc_is_home_page()) echo  osc_get_osclass_section() ?>[/b]<? if (osc_is_home_page()) echo meta_title(); ?><? if (osc_is_search_page()) echo meta_title(); ?> </title>

What I'm trying to do is display the region name of city..so, i try with :

Code: [Select]
<? if (osc_is_home_page()) echo  osc_get_osclass_[b]section[/b]() ?>
and

Code: [Select]
  <? if (osc_is_home_page()) echo  osc_get_osclass_[b]location[/b]() ?>

without positive results, i have tried with helpers (  https://doc.osclass.org/HDefines.php )..or even :


Code: [Select]
  <? if (osc_is_home_page()) echo  osc_get_osclass_[b]region[/b]() ?>
Code: [Select]
  <? if (osc_is_home_page()) echo osc_region_name() ?>
but the machien say - no!


Someone can help me plz.


best regard
« Last Edit: March 17, 2017, 07:05:51 pm by altavista »

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #1 on: March 17, 2017, 07:15:13 pm »
Hi,

Is it osc_search_city() giving you the correct name of the city in homepage?

Regards

altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #2 on: March 17, 2017, 07:22:30 pm »
Hi,

Is it osc_search_city() giving you the correct name of the city in homepage?

Regards

is not for search city.. is for home page city... i have also dealt with :

Code: [Select]
<? if (osc_is_home_page()); echo osc_region_name();?>
ut of course, I think it does not give anything because it's not home, is city home


but, only :
Code: [Select]
<? echo osc_region_name();?>..not give anything
« Last Edit: March 17, 2017, 07:28:17 pm by altavista »

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #3 on: March 17, 2017, 07:46:08 pm »
is not for search city.. is for home page city...

Yes, I was thinking that might work there, no real experience with city subdomains... And osc_subdomain_name()?




altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #4 on: March 17, 2017, 07:49:59 pm »
is not for search city.. is for home page city...

Yes, I was thinking that might work there, no real experience with city subdomains... And osc_subdomain_name()?

Thanks for your reply..

Code: [Select]
osc_subdomain_name()
not give me the region name.

If I find nothing, I will have to add the acronym of the region to each city : e.g :

Central - AK

Orlando -FL

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #5 on: March 17, 2017, 07:52:07 pm »
Code: [Select]
osc_subdomain_name()
not give me the region name.

I wasn't expecting that, the thing would be more tricky, just want to know if osc_subdomain_name() gives you the name of the city or what

altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #6 on: March 17, 2017, 08:01:24 pm »
Code: [Select]
osc_subdomain_name()
not give me the region name.

I wasn't expecting that, the thing would be more tricky, just want to know if osc_subdomain_name() gives you the name of the city or what

Yes, give me the city name.

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #7 on: March 17, 2017, 08:26:05 pm »
Code: [Select]
$city = City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST]));
$region = Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

Then $city['s_name'] is the name of the city, and $region['s_name'] is the name of the region.

Regards


altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #8 on: March 17, 2017, 08:45:28 pm »
Code: [Select]
$city = City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST]));
$region = Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

Then $city['s_name'] is the name of the city, and $region['s_name'] is the name of the region.

Regards

nop work for me...It gives me nothing

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #9 on: March 17, 2017, 09:24:00 pm »
Please paste here your testing code including these two lines.

altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #10 on: March 17, 2017, 11:02:36 pm »
Please paste here your testing code including these two lines.

Those two lines do not give me any results.

Code: [Select]
<? echo $region = Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']); ?>
<? echo $city = City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST]));; ?>

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #11 on: March 17, 2017, 11:08:44 pm »
No, those two lines are there just to prepare the data:

Code: [Select]
$city = City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST]));
$region = Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

echo "City name: " . $city['s_name'];
echo "Region name: " . $region['s_name'];

altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #12 on: March 18, 2017, 12:14:58 am »
No, those two lines are there just to prepare the data:

Code: [Select]
$city = City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST]));
$region = Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

echo "City name: " . $city['s_name'];
echo "Region name: " . $region['s_name'];

Sorry, my knowledge is not so deep, how should I use that?

teseo

  • Hero Member
  • *****
  • Posts: 5686
Re: If is location city home ? - ( get region name ? )
« Reply #13 on: March 18, 2017, 12:53:49 am »
What I'm trying to do is display the region name of city..so, i try with :

Code: [Select]
<? if (osc_is_home_page()) echo  osc_get_osclass_[b]section[/b]() ?>

So:

Code: [Select]
<?php
$city 
City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~""$1"$_SERVER[HTTP_HOST]));
$region Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

if (
osc_is_home_page()) echo  $region['s_name']; ?>


altavista

  • Jr. Member
  • **
  • Posts: 71
Re: If is location city home ? - ( get region name ? )
« Reply #14 on: March 18, 2017, 02:18:17 am »
What I'm trying to do is display the region name of city..so, i try with :

Code: [Select]
<? if (osc_is_home_page()) echo  osc_get_osclass_[b]section[/b]() ?>

So:

Code: [Select]
<?php
$city 
City::newInstance()->findBySlug(preg_replace("~^(.*?)\..*$~""$1"$_SERVER[HTTP_HOST]));
$region Region::newInstance()->findByPrimaryKey($city['fk_i_region_id']);

if (
osc_is_home_page()) echo  $region['s_name']; ?>


o lord.. works great, Lesson learned, thanks for your time.