Last active
July 9, 2017 14:25
-
-
Save kpion/a21ad1b1dcf8c15b8a36cc9e68be3425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function defaultMethod() { | |
lib::$view->assign("pageTemplate", $this->templateDir."cities.tpl"); | |
$cityId = 2; | |
$defaultCityIds = '2, 3, 7, 12'; | |
$cityIds = null; | |
if (isset($_GET['city']) && !empty($_GET['city'])) { | |
$cityId = $_GET['city']; | |
$cityIds = $_GET['city']; | |
}else{ | |
$cityIds = $defaultCityIds; | |
} | |
$city = lib::$db->GetAll("SELECT * FROM cities WHERE id_city = $cityId"); | |
$cities = lib::$db->GetAll("SELECT * FROM cities WHERE id_city IN ($defaultCityIds)"); | |
$isLogged = auth::isLoggedIn(); | |
lib::$view->assign("isLogged", $isLogged); | |
lib::$view->assign("city", $city[0]); | |
lib::$view->assign("cities", $cities); | |
$this->getProfiles($cityId); | |
$this->getSpaces($cityId); | |
$this->getJobs($cityIds); | |
$this->getEvents($cityId); | |
} | |
/** | |
@param $cityIds - one ID (integer) or many, like string - "1,2,3" | |
/* | |
public function getJobs($cityIds) { | |
if(is_array($cityIds)){ | |
$cityIds = implode(',',$cityIds); | |
} | |
$jobs = lib::$db->GetAll("SELECT | |
j.*, | |
s.name AS space, | |
s.page_url AS space_url | |
FROM job_posts AS j | |
LEFT JOIN spaces AS s ON j.id_space = s.id_space | |
WHERE j.id_city IN ($cityIds) | |
AND j.id_plan IN (1, 2) | |
LIMIT 3"); | |
lib::$view->assign("jobs", $jobs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment