Skip to content

Instantly share code, notes, and snippets.

@gregbarcza
Created February 17, 2013 22:19
Show Gist options
  • Save gregbarcza/4973799 to your computer and use it in GitHub Desktop.
Save gregbarcza/4973799 to your computer and use it in GitHub Desktop.
<?php
public function streams_attribute($param, $default = NULL)
{
$value = $this->attribute($param, $default);
// See if we have any vars in there
if(strpos($value, '[') !== FALSE):
$segs = array(
'segment_1' => $this->uri->segment(1,$this->attribute('segment_def')),
'segment_2' => $this->uri->segment(2,$this->attribute('segment_def')),
'segment_3' => $this->uri->segment(3,$this->attribute('segment_def')),
'segment_4' => $this->uri->segment(4,$this->attribute('segment_def')),
'segment_5' => $this->uri->segment(5,$this->attribute('segment_def')),
'segment_6' => $this->uri->segment(6,$this->attribute('segment_def')),
'segment_7' => $this->uri->segment(7,$this->attribute('segment_def')),
);
// We can only get the user data if it is available
if($this->current_user):
$segs['user_id'] = $this->current_user->id;
$segs['username'] = $this->current_user->username;
endif;
foreach($segs as $seg_marker => $segment_value):
$value = str_replace("[$seg_marker]", $segment_value, $value);
endforeach;
endif;
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment