-
-
Save druu/3930934 to your computer and use it in GitHub Desktop.
presenter photos thing
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
<?php // my view ?> | |
<h1><?php echo $album_info['0']['album_name'] ?></h1> | |
<a href="/photos/<?php echo $album_info['0']['album_year'] ?>" title="Back to Albums">Back to Albums</a> | |
<ul class="photo-items"> | |
<?php foreach($album_photos as $k => $v) {$album_photos[$k] = (object) $v;} ?> | |
<?php $album_presenter->partial('list_photos'); ?> | |
</ul> | |
<div class="top_link"><a class="smooth_ride" href="<?php $_SERVER['REQUEST_URI'] ?>#top">Back to top</a></div> |
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
<?php // presenter | |
class Album_presenter extends Presenter { | |
public $v_map = array( | |
'class' => array('photo_width', 'photo_height'), | |
'url' => array('photo_link'), | |
); | |
public function transform_photo_link($url) | |
{ | |
return substr($url,0,-5); | |
} | |
public function transform_class($width, $height) | |
{ | |
if($height > 250){$class = 'vertical';}else if($height < 160){$class = 'smaller';}else{$class = '';} | |
if($width < 240){$class .= ' thin';} | |
return $class; | |
} | |
public function transform_url($url) | |
{ | |
$url = explode('/',$url); | |
return substr($url[4],0,-6); | |
//return 'meow'; | |
} | |
} |
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
<?php //my partial thing, located in partials/album/list_photos.php ?> | |
<li> | |
<div class="thumbBox"> | |
<div class="thumb photo"> | |
<a href="#photo_link#n.jpg" class="fancybox" title=""> | |
<img class="lazy" data-original="/uploads/images/photos/#url#.jpg" alt="" width="240" /> | |
</a> | |
</div> | |
</div> | |
</li> |
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
$album = ('photo_id'=>'', 'album_id'=>'', 'photo_link'=>'', 'photo_link_hr'=>'', 'photo_link_fb'=>'', 'photo_width'=>'', 'photo_height'=>'', 'photo_auth'=>'', 'photo_da'=>'', 'photo_du'=>''); |
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
<?php // controller method ?> | |
public function album($album_slug) | |
{ | |
// Somehow THIS array also needs to get into the partial loop. | |
$data['album_info'] = $this->photos_model->get_album_info($album_slug); | |
if (empty($data['album_info'])) | |
{ | |
show_404(); | |
} | |
// main photos array | |
$album = $this->photos_model->get_album($data['album_info']['0']['album_id']); | |
if (empty($album)) | |
{ | |
show_404(); | |
} | |
$data['title'] = $data['album_info']['0']['album_name']; | |
$data['album_presenter'] = $this->presenter->create('album', $album); | |
$this->load->view('templates/header', $data); | |
$this->load->view('photos/album', $data); | |
$this->load->view('templates/footer'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment