Tips for Yii. Chapter 13.
Cookie and subdomains.
If your website has multiple subdomains, it will be better to store user authorization both on your primary domain and on subdomains.
For example:the primary domain is http://domain_site.com. The subdomains are http://msk.domain_site.com and http://spb.domain_site.com.
User logged on http://domain_site.com, but he willbe the "guest" not an "authorized user" on http://msk.domain_site.com.
If you want to avoid such misunderstanding, you need to find the configuration file (for example: protected\config\main.php) and just add to "components" section the following code:
and
In summary, it has to look like this:
After these changes, you have to clear cookie in your browser plus the script's cache.
The cache of the script is usually stored in protected/runtime/cache.
However, you can specify a folder for cache's storage. This can be done in the configuration file.
Write this:
After:
After that, the cache will be stored from the "root" of the site (where index.php is) in "my_cache_folder".
Sorting according to the distance from the current object.
Task: By viewing a listing using Open Real Estate CMS, output "Similar listings" in order of distance increasing from the current location of the object.
Solution:
The location coordinates of each object (listing) are stored in the table {prefix}_apartment. The fieldslat and lng.
"viewSimilarAds" method is responsible for structuring of similar listings facility ($criteria) in the file protected\modules\similarads\components\SimilarAdsWidget.php.
In this file instead of:
Write this:
"3959" is the radius of the earth in miles and "40" is the maximum distance in miles.
You can also withdraw the distance from the viewed object.
Find this file protected\modules\apartments\models\Apartment.php and after:
add:
Then in protected\modules\similarads\views\widgetSimilarAds_list.php, after:
add: