Skip to content

Commit

Permalink
add permalink.php and get_block method
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoski committed Oct 25, 2012
1 parent 0279ef2 commit 70be91c
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
5 changes: 5 additions & 0 deletions arena.php
Expand Up @@ -22,6 +22,11 @@ function get_channel($slug = null, $options = null){
return new Channel($request->data);
}

function get_block($id = null){
$request = new Request("blocks/$id");
return new Block($request->data);
}

function set_page() {
if(isset($_GET['page'])){
return $_GET['page'];
Expand Down
2 changes: 1 addition & 1 deletion examples/1_document/index.php
Expand Up @@ -64,7 +64,7 @@
<?php $channel->each_item(function($item) {?>

<div class="item <?= $item->css_class()?>">
<h3><?= $item->generated_title ?></h3>
<h3><?= $item->generated_title ?> [<a href="permalink.php?id=<?= $item->id?>">#</a>]</h3>
<div class="blog-content">

<?php if($item->is_image()) { ?>
Expand Down
82 changes: 82 additions & 0 deletions examples/1_document/permalink.php
@@ -0,0 +1,82 @@
<?php

/*
* Arena Document Example / Permalink
*
*
*/

include '../../arena.php';

$arena = new Arena();

$item = $arena->get_block($_GET['id']);
print_r($block);
?>

<!DOCTYPE html>
<html>
<head>
<title><?= $channel->title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/Core/Modernist" type="text/css">
<style type="text/css">
img, iframe{padding-left: 11%;}
p, p:first-child{padding-right: 11%}
div > p:first-child, body > p:first-child, td > p:first-child{padding-right: 11%}
a.img{background-color: #fff;}
</style>
</head>
<body>

<div id="contents">
<div class="item <?= $item->css_class()?>">
<h3><?= $item->generated_title ?></h3>
<div class="blog-content">

<?php if($item->is_image()) { ?>
<a class='img' href="<?= $item->image_url('original') ?>">
<img src="<?= $item->image_url('display') ?>" />
</a>
<div class="blog-post-description">
<?= $item->description_html ?>
</div>
<?php } ?>

<?php if($item->is_link()){ ?>
<a class='img' href="<?= $item->source['url'] ?>">
<img src="<?= $item->image_url('display') ?>">
</a>
<div class="blog-post-description">
<?= $item->description_html ?>
</div>
<?php } ?>

<?php if($item->is_text()){ ?>
<div class="blog-post-entry-content">
<p><?= $item->content_html ?></p>
</div>
<div class="blog-post-description">
<?= $item->description_html ?>
</div>
<?php } ?>

<?php if($item->is_embed()){ ?>
<div class="blog-post-entry-content">
<?= $item->embed['html'] ?>
</div>
<div class="blog-post-description">
<?= $item->description_html ?>
</div>
<?php } ?>


<?php if($item->is_attachment()){ ?>
<p><?= $item->attachment['file_name'] ?> <a href="<?= $item->attachment['url'] ?>">(download)</a></p>
<?php } ?>
</div>
<h3><a href="index.php">Back</a></h3>
</div>
</div>
</body>
</html>

0 comments on commit 70be91c

Please sign in to comment.