Advertisement:

Author Topic: how to print the current city name the user is viewing  (Read 2959 times)

mandi007

  • Full Member
  • ***
  • Posts: 204
how to print the current city name the user is viewing
« on: June 06, 2014, 09:02:29 am »
i used the <?php _e(osc_city() ); ?> 


but it is giving some Project-Id-Version: Osclass Report-Msgid-Bugs-To: http://osclass.org/ POT-Creation-Date: 2013-12-03 16:09:49+00:00 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PO-Revision-Date: 2013-12-03 17:37+0100 Last-Translator: _CONEJO Language-Team: Translations


please give me some suggestions

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1198
Re: how to print the current city name the user is viewing
« Reply #1 on: June 06, 2014, 09:41:12 am »
Hi,
 try

<?php echo osc_city(); ?>

the _e() is calling the translation file.

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #2 on: June 06, 2014, 10:07:53 am »
not returing anything........


blank output

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to print the current city name the user is viewing
« Reply #3 on: June 06, 2014, 01:34:08 pm »
Hi,

Should be osc_city_name()

Regards

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #4 on: June 06, 2014, 02:47:33 pm »
i tried
 echo osc_city();
 echo osc_city_name();
echo osc_region();
 echo osc_country();
 echo osc_region_name();
no result nothing is shwing

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to print the current city name the user is viewing
« Reply #5 on: June 06, 2014, 02:55:18 pm »
What theme are you using?

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #6 on: June 06, 2014, 03:23:39 pm »
modern theme

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to print the current city name the user is viewing
« Reply #7 on: June 06, 2014, 03:50:09 pm »
I assume you're not referring to item view (I think osc_city_name() should work there), but search page (Ads list), try this:

<?php echo Params::getParam('sCity'); ?>

Regards

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #8 on: June 06, 2014, 03:57:13 pm »
No actually what i want is .....if a user come to my site and if he choose a subdomain  say for example chennai and after clicking it i want to show in home page like "find ads in chennai" for registered and also not registered user.  i want to print the user current viewing location name in homepage

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to print the current city name the user is viewing
« Reply #9 on: June 06, 2014, 04:21:27 pm »
You should have started explaining exactly that, a lot of time wasted here...  :-\

Sorry, no experience with subdomains. You might extract the city part of the subdomain:

<?php echo ucwords(preg_replace("~http://(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST])); ?>

This should give you "Chennai" when your enter http://chennai.yourdomain.com, but wouldn't cover cities with name having more than one word. If you have any I'd need to know how the URL looks like... For instance, "Ashok Nagar" would appear as http://ashok-nagar.yourdomain.com?  ???

Regards

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #10 on: June 06, 2014, 08:40:14 pm »
it is giving chennai.domainname.com . how to make it to show only chennai

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: how to print the current city name the user is viewing
« Reply #11 on: June 06, 2014, 08:53:28 pm »
My mistake, no http:// there:

<?php echo ucwords(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST])); ?>

mandi007

  • Full Member
  • ***
  • Posts: 204
Re: how to print the current city name the user is viewing
« Reply #12 on: June 08, 2014, 08:35:36 pm »
great ...thank you

omid_firoznia

  • Newbie
  • *
  • Posts: 37
Re: how to print the current city name the user is viewing
« Reply #13 on: January 19, 2019, 11:02:26 pm »
Hi
many thanks for :
<?php echo ucwords(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST])); ?>

but right now its print | (s_slug) | please let me know what is i have to change, that it print | (s_name) |?

what i want exactly is when any users (registered or not registered) going to a region or a city url, the name of that region Or city showing up before or after logo.




i put it in header.php as below:

-----------------------------------------------------------------------------
......
    </div>
    <div class="clear"></div>
    <div class="wrapper">
        <div id="logo"><?php echo ucwords(preg_replace("~^(.*?)\..*$~", "$1", $_SERVER[HTTP_HOST])); ?>
            <?php echo logo_header(); ?>
......
-----------------------------------------------------------------------------
« Last Edit: January 19, 2019, 11:48:25 pm by omid_firoznia »

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: how to print the current city name the user is viewing
« Reply #14 on: January 20, 2019, 01:55:33 am »
Hello,

To show the current search city use <?php echo osc_search_city(); ?>. The code that @teseo provided was for subdomains.

Regards.