aboutsummaryrefslogtreecommitdiff
path: root/mod/blog
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-16 09:20:51 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-04-16 09:20:51 +0000
commit2216b3352edd95a4df2745996e7d3c741efc3284 (patch)
treef26f46420aa28b673aa88d7e16aab9cdf3cd8937 /mod/blog
parentf57931837fb8594c0fff76d1fa184f5aacad68cb (diff)
downloadelgg-2216b3352edd95a4df2745996e7d3c741efc3284.tar.gz
elgg-2216b3352edd95a4df2745996e7d3c741efc3284.tar.bz2
Blog plugin now serves as a fancy URL example
git-svn-id: https://code.elgg.org/elgg/trunk@473 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/blog')
-rw-r--r--mod/blog/start.php41
-rw-r--r--mod/blog/views/default/object/blog.php4
2 files changed, 40 insertions, 5 deletions
diff --git a/mod/blog/start.php b/mod/blog/start.php
index 0a3a50cd8..f8af95e17 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -30,14 +30,14 @@
// Set up menu for logged in users
if (isloggedin()) {
- add_menu(elgg_echo('blog'), $CONFIG->wwwroot . "mod/blog/",array(
- menu_item(elgg_echo('blog:read'),$CONFIG->wwwroot."mod/blog/?username=" . $_SESSION['user']->username),
+ add_menu(elgg_echo('blog'), $CONFIG->wwwroot . "blog/",array(
+ menu_item(elgg_echo('blog:read'),$CONFIG->wwwroot."blog/" . $_SESSION['user']->username),
menu_item(elgg_echo('blog:addpost'),$CONFIG->wwwroot."mod/blog/add.php"),
menu_item(elgg_echo('blog:everyone'),$CONFIG->wwwroot."mod/blog/everyone.php"),
));
// And for logged out users
} else {
- add_menu(elgg_echo('blog'), $CONFIG->wwwroot . "mod/blog/",array(
+ add_menu(elgg_echo('blog'), $CONFIG->wwwroot . "mod/blog/everyone.php",array(
menu_item(elgg_echo('blog:everyone'),$CONFIG->wwwroot."mod/blog/everyone.php"),
));
}
@@ -45,6 +45,41 @@
// Extend system CSS with our own styles, which are defined in the blog/css view
extend_view('css','blog/css');
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('blog','blog_page_handler');
+
+ }
+
+ /**
+ * Blog page handler; allows the use of fancy URLs
+ *
+ * @param array $page From the page_handler function
+ * @return true|false Depending on success
+ */
+ function blog_page_handler($page) {
+
+ // The first component of a blog URL is the username
+ if (isset($page[0])) {
+ set_input('username',$page[0]);
+ }
+
+ // The second part dictates what we're doing
+ if (isset($page[1])) {
+ switch($page[1]) {
+ case "read": set_input('blogpost',$page[2]);
+ @include(dirname(__FILE__) . "/read.php");
+ break;
+ case "friends": // TODO: add friends blog page here
+ break;
+ }
+ // If the URL is just 'blog/username', or just 'blog/', load the standard blog index
+ } else {
+ @include(dirname(__FILE__) . "/index.php");
+ return true;
+ }
+
+ return false;
+
}
// Make sure the blog initialisation function is called on initialisation
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
index c4b718045..52c03d23b 100644
--- a/mod/blog/views/default/object/blog.php
+++ b/mod/blog/views/default/object/blog.php
@@ -17,7 +17,7 @@
?>
<div class="blog-post">
- <h3><a href="<?php echo $vars['url']; ?>mod/blog/read.php?blogpost=<?php echo $vars['entity']->getGUID(); ?>"><?php echo $vars['entity']->title; ?></a></h3>
+ <h3><a href="<?php echo $vars['url']; ?>blog/<?php echo $vars['entity_owner']->username; ?>/read/<?php echo $vars['entity']->getGUID(); ?>"><?php echo $vars['entity']->title; ?></a></h3>
<p class="strapline">
<span style="float:right">
<?php
@@ -28,7 +28,7 @@
?>
</span>
- <a href="<?php echo $vars['url']; ?>mod/blog/?username=<?php echo $vars['entity_owner']->username; ?>"><?php echo $vars['entity_owner']->name; ?></a>
+ <a href="<?php echo $vars['url']; ?>blog/<?php echo $vars['entity_owner']->username; ?>"><?php echo $vars['entity_owner']->name; ?></a>
</p>
<p>
<?php