Get Tag links per post like Blog Module
I would like to generate tag links for my event module record class just like how the Blog Posts model class handles it.
However I'm a bit confused on how to generate the right parameters for the anchor function. So I would like to generate links of this format: www.example.com/events/tags/car
function get_tags_linked($order = 'name asc', $join = ', ', $link_params = array())
{
$tags = $this->tags;
if ( ! empty($tags))
{
$tags_linked = array();
foreach ($tags as $tag)
{
$tags_linked[] = anchor($this->_CI->fuel->blog->url($tag->get_url(FALSE)), $tag->name, $link_params);
}
$return = implode($tags_linked, $join);
return $return;
}
return NULL;
}
Comments
$this->_CI->fuel->blog->url($tag->get_url(FALSE)), $tag->name, $link_params);
That is the URL that is generated from the blog and the tag. In your case, you would want something like the following:
... $tags_linked[] = anchor(site_url('events/tags/'.$tag->slug), $tag->name, $link_params); ...
I assume it's because of how I handle the requests for event tags to my tags view.
$pages['events/tags/:any'] = array('view' => 'events/tags');
Do you have any clue why this is happening? I've ran into this before with CodeIgniter.
<?php
$slug = uri_segment(3);
if ($slug) :
$tag = $CI->fuel->tags->find_by_tag($slug);
if (empty($tag)) :
redirect_404();
endif;
$events_model = $tag->get_events(TRUE);
$events = $events_model->find_all(array('event_startdate >=' => datetime_now()), 'event_startdate', $limit, $offset, NULL, NULL);
$vars['events'] = $events;
endif;
?>
<?=ucfirst($slug)?> Events
<?=$this->load->view('_blocks/event_posts', $vars)?>P.S. how do I markdown code by the way?