Advertisement:

Author Topic: [TUTORIAL] How to make City and Regions specific main pages  (Read 31592 times)

computerbar

  • Tutor
  • Sr. Member
  • *
  • Posts: 279
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #30 on: February 04, 2013, 12:35:16 am »
thanks for reporting it.
you are right. this part I have not figured out yet.
I commented out the <!-- <span>(<?php echo osc_category_total_items() ; ?>)</span>--> in myhome.php in theme folder.
to hide the count on myhome page i,e the cout wont show on regoin and city but will still the total on main page.
 

danz0l

  • Newbie
  • *
  • Posts: 3
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #31 on: February 04, 2013, 12:25:35 pm »
Thanks computerbar. Your almost fully there but as it stands it would confuse users. The region states it has articles and it does indeed change to the region once clicked. But its near impossible to know where those ads are within the categories. I wonder if, on the myhome.php for region we can perform a category search through mysql with an AND statement to check that region set is the one the viewer is currently browsing. Its been such a long time since i have done any php or mysql and i have to admit to being very very rusty but it should be a case of checking both categories and regions to see what posts related to which category.

So checking the region && the subcategories count specific to having ads & relating to the region we are in you'd modify the for / next loop to display counts only related to that region (hope you understand what i mean by that).

Then it would be a case of slightly modifying the category display loop in your new myhome.php

                                <ul>
                                    <?php while ( osc_has_subcategories() && REGION==CURRENT REGION SELECTED ) { ?>
                                        <li><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span></li>
                                    <?php } ?>
                                </ul>

I'd have to get back to php and mysql basics to see if i can understand the code and i've only had a very quick look at the code with no mysql database examination but i think its doable. As you've been in the code it may spark an idea your end perhaps ?

Aficionado

  • Guest
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #32 on: April 01, 2013, 06:04:50 am »
Hi,

What if i want to do all the above for COUNTRIES ?

tnks

SemperSaint

  • Newbie
  • *
  • Posts: 20
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #33 on: April 11, 2013, 11:47:48 pm »
This is what I did, and it seemed to work for what I wanted.  I only wanted states that had listings to show.  I simply commented out three lines of code in my main.php as follows:

                <?php if ( !View::newInstance()->_exists('list_contries') ) {
//                            View::newInstance()->_exportVariableToView('list_regions', Search::newInstance()->listRegions('%%%%', '>=', 'region_name ASC') ) ;
//                      }
//                      if( osc_count_list_regions() ) { ?>


After that, all that showed on my main page was North Carolina which  is the only state I have listings posted in.  Then I tested it by making a listing in Louisiana, and only North Carolina and Louisiana showed on the main page.  You can take a look at http://sempernet.com

« Last Edit: April 12, 2013, 12:01:21 am by SemperSaint »

shamell

  • Newbie
  • *
  • Posts: 5

Aficionado

  • Guest
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #35 on: May 14, 2013, 10:33:32 pm »
i wonder if it was possible to do something like this http://czesc.ca/index.php?page=search&sCategory=business-equipment&sPattern=tomas&sRegion=Quebec&sCity=Gatineau-Hull


Me too. A few weeks ago i emailed the owner of the site, but got no reply.


baddad

  • Newbie
  • *
  • Posts: 30
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #36 on: May 21, 2013, 07:24:55 pm »
Hi thanks for the information herein.  I have a request and are not sure if it was satisfied elsewhere on the forum....  How will I achieve the following : when a user visit my site I want to use his IP adress to list the ads in his region automatically?
Any assistance will be greatly appreciated.

www.wireworm.co.za

sirjones

  • Full Member
  • ***
  • Posts: 102
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #37 on: June 05, 2013, 04:31:13 pm »
and then how to show city/region ads according on user's profile?
thanks in advance

skr678

  • Jr. Member
  • **
  • Posts: 52
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #38 on: June 08, 2013, 07:26:28 am »
Does this tutorial apply to v3.1.2?  I can't seem to find search.php in my root folder.

This is exactly what I am hoping to implement on the USA theme.

Thank you

skr678

  • Jr. Member
  • **
  • Posts: 52
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #39 on: June 10, 2013, 03:46:10 am »
thanks for reporting it.
you are right. this part I have not figured out yet.
I commented out the <!-- <span>(<?php echo osc_category_total_items() ; ?>)</span>--> in myhome.php in theme folder.
to hide the count on myhome page i,e the cout wont show on regoin and city but will still the total on main page.

I have implemented the mod on the usa theme and aside from trying to figure out how to change the links for states from search to myhome, it seems to be working well. Thank you for the great tutorial; your explanation of the logic really helped!

Regarding the category/subcategory ad counts for regions, was a solution found?  If not, commenting that out in the myhome in theme will just eliminate the counts from the region pages correct?


Hostingames

  • Full Member
  • ***
  • Posts: 189
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #40 on: June 13, 2013, 07:48:16 pm »
hi
edit my file before I'd have a screen capture to see the diference thank you

sirjones

  • Full Member
  • ***
  • Posts: 102
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #41 on: June 14, 2013, 07:27:18 am »
again...
if user has city let say Tokyo (in user details)
how can i automatically show ads base on user's city?
Many thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #42 on: June 14, 2013, 10:26:44 am »
Well, problem is there is no function osc_logged_user_city(),  :-\ but we can create an equivalent:

Code: [Select]
function cust_logged_user_city() {
    $user = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
    return $user['s_city'];
}

And this is a loop that would iterate through items in the user city:

Code: [Select]
<?php
        osc_query_item
(array('city_name'=> cust_logged_user_city())) ;
        while ( 
osc_has_custom_items()) {

// Here the contents for each item, just like they are presented in latest_items, for example

}

Insert the function in your functions.php and the main code where you want to show this kind of list. More variables might be added, like order of the ads, only premiums, or number of them to be shown.

Regards

sirjones

  • Full Member
  • ***
  • Posts: 102
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #43 on: June 14, 2013, 08:27:52 pm »
great n thanks :)

Daniel1

  • Newbie
  • *
  • Posts: 6
Re: [TUTORIAL] How to make City and Regions specific main pages
« Reply #44 on: June 15, 2013, 06:17:52 pm »
Hello

Would you please update this tutorial to work with 3.1.2

I managed to create myhome , but I cant browse categories or filter it based on Region/City


Thank you