Advertisement
Guest User

Untitled

a guest
Sep 26th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.93 KB | None | 0 0
  1. sub main {
  2.     my $self = shift;
  3.     my $uri = $self->stash('uri');
  4.     if(defined($uri)) {
  5.         my $page_existance = $dbh->prepare(qq{SELECT COUNT(1) FROM pages WHERE uri = '$uri'});
  6.         $page_existance->execute();
  7.             if ($page_existance->fetch()->[0]) {
  8.             # Template was found for URI specified, so let's render it.
  9.                 my $uri_template = $dbh->prepare(qq{SELECT template FROM pages WHERE uri = '$uri' AND active = '1'});
  10.                 $uri_template->execute();
  11.                 $uri_template->bind_columns(\my($template));
  12.                 $uri_template->fetch();
  13.                 $self->render('$template', format => 'html');
  14.                 } else {
  15.                 # No template was found for the URI specified.
  16.                 $self->render('404', message => 'Sorry, this page does not seem to exist.', status => '404');
  17.                 }
  18.                 } else {
  19.                 # URI is not defined. ## todo: redirect_to index.
  20.                 $self->render('404', message => 'Sorry, you need to specify a page you wish to view.', status => '404');
  21.                 }
  22. }
  23. 1;             
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement