Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add DiscussionUrl() function.

  • Loading branch information...
commit 93d587dda1069e74c05952dd4015a43733a0217d 1 parent 52bd574
Todd Burry tburry authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 library/core/functions.render.php
19 library/core/functions.render.php
View
@@ -97,6 +97,25 @@ function Anchor($Text, $Destination = '', $CssClass = '', $Attributes = '', $For
}
}
+if (!function_exists('DiscussionUrl')):
+
+/**
+ * Return a url for a discussion. This function is in here and not functions.general so that plugins can override.
+ * @param object $Discussion
+ * @return string
+ */
+function DiscussionUrl($Discussion, $Page = '', $WithDomain = TRUE) {
+ $Discussion = (object)$Discussion;
+ $Result = '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name);
+ if ($Page) {
+ if ($Page > 1 || Gdn::Session()->UserID)
+ $Result .= '/p'.$Page;
+ }
+ return Url($Result, $WithDomain);
+}
+
+endif;
+
if (!function_exists('FixNl2Br')) {
/**
* Removes the break above and below tags that have a natural margin.
Please sign in to comment.
Something went wrong with that request. Please try again.