[eluser]johnmerlino[/eluser]
Hey all,
While I can generate the vanity url in the url, since there is no view with such a name, I'm not sure how to render a view.
For example, I have this in routes:
Code:
$route['blogs/(:any)'] = "blogs/get_blogger";
Basically if someone types in blogs/johnmerlino in the url, it will call the get_blogger method, which does this:
Code:
public function get_blogger(){
$user_name = $this->uri->segment(2);
$u = new User();
$u->where('user_name',$user_name);
$u->get();
$data = $u->post->get();
$options['records'] = $data;
$defaults = array('head' => 'Blog', 'subhead' => 'This is the' . $u->first_name . ' ' . $u->last_name . 'blog page.' , 'current_user' => $this->current_user());
$result = array_merge($defaults,$options);
$this->template->render_content('template', "/blogs/{$u->user_name}", $result);
}
So basically I find the user record in the database that matches the uri second string. I then return the user record as an object and posts associated with that user as an object. However, when I go to load the page with the render_content method which does the same thing as the default codeigniter method but places the code in a template, I get the following error:
Code:
An Error Was Encountered
Unable to load the requested file: /blogs/johnmerlino.php
I get this error because I have no view in my blogs directory called johnmerlino. However, it doesn't sound feasible to dynamically create a view file for that user when they sign up in that directory. So I am curious how everyone else does it?
Thanks for response.