Skip to content

Instantly share code, notes, and snippets.

@slywalker
Created December 22, 2009 05:25
Show Gist options
  • Save slywalker/261524 to your computer and use it in GitHub Desktop.
Save slywalker/261524 to your computer and use it in GitHub Desktop.
<?php
public function area_tag($area_id = null, $tag_id = null) {
if (!$area_id || !$tag_id) {
$this->Session->setFlash(__('Invalid Shop', true));
$this->redirect(array('action'=>'index'));
}
$this->paginate = array(
'conditions' => array(
'Shop.is_hidden' => 0,
'AreasShop.area_id' => $area_id,
'ProfilesTag.tag_id' => $tag_id,
),
'fields' => array('Shop.*', 'COUNT(ProfilesTag.id) AS `count`'),
'joins' => array(
array(
'table' => 'areas_shops',
'alias' => 'AreasShop',
'type' => 'INNER',
'conditions' => array('Shop.id = AreasShop.shop_id'),
),
array(
'table' => 'profiles_tags',
'alias' => 'ProfilesTag',
'type' => 'INNER',
'conditions' => array('Shop.id = ProfilesTag.shop_id'),
),
),
'group' => 'Shop.id, ProfilesTag.tag_id',
'order' => array('count' => 'DESC'),
'contain' => array(
'Post' => array(
'limit' => 1,
'Attachment',
),
'ProfilesTag' => array(
'conditions' => array('ProfilesTag.tag_id' => $tag_id),
'Profile' => array(
'fields' => array('id', 'profile_name'),
'conditions' => array('Profile.is_hidden' => 0),
'Attachment',
'Latency' => array('conditions' => array('Latency.latency_datetime >' => date('Y-m-d H:i:s', strtotime('now -1 hour')))),
),
),
'Course' => array(
'conditions' => array('Course.is_main' => 1),
),
),
'foreignKey' => false,
);
$this->set('shops', $this->paginate());
$this->set('area', $this->Shop->Area->read(array('id', 'area'), $area_id));
$this->set('tag', $this->Shop->ProfilesTag->Tag->read(array('id', 'tag'), $tag_id));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment