Skip to content
This repository
Browse code

Added ability to set default view block content

  • Loading branch information...
commit 6d98069f1349b6173ebb1b2476bf3417c05715e6 1 parent 07c5102
Tigran Gabrielyan authored September 13, 2012
6  lib/Cake/View/View.php
@@ -636,11 +636,11 @@ public function assign($name, $value) {
636 636
  * empty or undefined '' will be returned.
637 637
  *
638 638
  * @param string $name Name of the block
639  
- * @return The block content or '' if the block does not exist.
  639
+ * @return string The block content or $default if the block does not exist.
640 640
  * @see ViewBlock::get()
641 641
  */
642  
-	public function fetch($name) {
643  
-		return $this->Blocks->get($name);
  642
+	public function fetch($name, $default = '') {
  643
+		return $this->Blocks->get($name, $default);
644 644
 	}
645 645
 
646 646
 /**
6  lib/Cake/View/ViewBlock.php
@@ -119,11 +119,11 @@ public function set($name, $value) {
119 119
  * Get the content for a block.
120 120
  *
121 121
  * @param string $name Name of the block
122  
- * @return The block content or '' if the block does not exist.
  122
+ * @return string The block content or $default if the block does not exist.
123 123
  */
124  
-	public function get($name) {
  124
+	public function get($name, $default = '') {
125 125
 		if (!isset($this->_blocks[$name])) {
126  
-			return '';
  126
+			return $default;
127 127
 		}
128 128
 		return $this->_blocks[$name];
129 129
 	}

0 notes on commit 6d98069

Please sign in to comment.
Something went wrong with that request. Please try again.