Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub main {
- my $self = shift;
- my $uri = $self->stash('uri');
- if(defined($uri)) {
- my $page_existance = $dbh->prepare(qq{SELECT COUNT(1) FROM pages WHERE uri = '$uri'});
- $page_existance->execute();
- if ($page_existance->fetch()->[0]) {
- # Template was found for URI specified, so let's render it.
- my $uri_template = $dbh->prepare(qq{SELECT template FROM pages WHERE uri = '$uri' AND active = '1'});
- $uri_template->execute();
- $uri_template->bind_columns(\my($template));
- $uri_template->fetch();
- $self->render('$template', format => 'html');
- } else {
- # No template was found for the URI specified.
- $self->render('404', message => 'Sorry, this page does not seem to exist.', status => '404');
- }
- } else {
- # URI is not defined. ## todo: redirect_to index.
- $self->render('404', message => 'Sorry, you need to specify a page you wish to view.', status => '404');
- }
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement