Permalink
Browse files

adds asset_path() method to properly load assets inside views

  • Loading branch information...
jackmcdade committed Mar 30, 2012
1 parent 407db7d commit 41834f5f5587b25019d72a405ab0e9a3b2e8548b
Showing with 21 additions and 6 deletions.
  1. +1 −0 content/20120330/assets/style.css
  2. +13 −6 content/20120330/index.php
  3. +7 −0 index.php
@@ -0,0 +1 @@
h1 {color:red;}
View
@@ -1,6 +1,13 @@
<h1><?= $title ?></h1>
<h6>May 30th.</h6>
<ul>
<?php if ($prev): ?><li><a href="<?php echo $prev ?>">Previous</a></li><?php endif ?>
<?php if ($next): ?><li><a href="<?php echo $next ?>">Next</a></li><?php endif ?>
</ul>
<!doctype html>
<head>
<link rel="stylesheet" href="<?php echo asset_path('assets/style.css'); ?>">
</head>
<body>
<h1><?= $title ?></h1>
<h6>May 30th.</h6>
<ul>
<?php if ($prev): ?><li><a href="<?php echo $prev ?>">Previous</a></li><?php endif ?>
<?php if ($next): ?><li><a href="<?php echo $next ?>">Next</a></li><?php endif ?>
</ul>
</body>
View
@@ -43,6 +43,7 @@ function get_meta($date) {
$initialize = array(
'title' => $app->config['defaultTitle'],
'date' => $date,
'prev' => find_prev($date),
'next' => find_next($date),
);
@@ -127,6 +128,12 @@ function get_endpoint($dir)
$dir_array = explode('/', $dir);
return end($dir_array);
}
function asset_path($asset) {
$app = Slim::getInstance();
return '/content'.$app->request()->getResourceUri().'/'.$asset;
}
//
/**

0 comments on commit 41834f5

Please sign in to comment.