Browse code

#13 Notice: Undefined index: featuredblock

Jimako authored on 2023/09/06 07:04:54
Showing 1 changed files
... ...
@@ -605,36 +605,38 @@ class TemplatePower extends TemplatePowerParser
605 605
      */
606 606
     public function newBlock($blockname)
607 607
     {
608
-        $parent = &$this->content[ $this->parent[$blockname] .'_'. $this->index[$this->parent[$blockname]] ];
608
+        if(isset($this->parent[$blockname])) {
609
+            $parent = &$this->content[ $this->parent[$blockname] .'_'. $this->index[$this->parent[$blockname]] ];
609 610
 
610
-		$lastitem = sizeof( $parent );
611
-        $lastitem > 1 ? $lastitem-- : $lastitem = 0;
611
+            $lastitem = sizeof( $parent );
612
+            $lastitem > 1 ? $lastitem-- : $lastitem = 0;
612 613
 
613
-		$ind_blockname = $blockname . '_' . $this->index[ $blockname ];
614
+            $ind_blockname = $blockname . '_' . $this->index[ $blockname ];
614 615
 
615
-        if (! isset($parent[ $lastitem ]["_B:$blockname"])) {
616
-            //ok, there is no block found in the parentblock with the name of {$blockname}
616
+            if (! isset($parent[ $lastitem ]["_B:$blockname"])) {
617
+                //ok, there is no block found in the parentblock with the name of {$blockname}
617 618
 
618
-            //so, increase the index counter and create a new {$blockname} block
619
-            $this->index[ $blockname ] += 1;
619
+                //so, increase the index counter and create a new {$blockname} block
620
+                $this->index[ $blockname ] += 1;
620 621
 
621
-            $ind_blockname = $blockname . '_' . $this->index[ $blockname ];
622
+                $ind_blockname = $blockname . '_' . $this->index[ $blockname ];
622 623
 
623
-            if (! isset($this->content[ $ind_blockname ])) {
624
-                 $this->content[ $ind_blockname ] = array();
625
-            }
624
+                if (! isset($this->content[ $ind_blockname ])) {
625
+                    $this->content[ $ind_blockname ] = array();
626
+                }
626 627
 
627
-            //tell the parent where his (possible) children are located
628
-            $parent[ $lastitem ]["_B:$blockname"] = $ind_blockname;
629
-        }
628
+                //tell the parent where his (possible) children are located
629
+                $parent[ $lastitem ]["_B:$blockname"] = $ind_blockname;
630
+            }
630 631
 
631
-        //now, make a copy of the block defenition
632
-        $blocksize = sizeof( $this->content[ $ind_blockname ] );
632
+            //now, make a copy of the block defenition
633
+            $blocksize = sizeof( $this->content[ $ind_blockname ] );
633 634
 
634
-        $this->content[ $ind_blockname ][ $blocksize ] = array( $blockname );
635
+            $this->content[ $ind_blockname ][ $blocksize ] = array( $blockname );
635 636
 
636
-        //link the current block to the block we just created
637
-        $this->currentBlock = &$this->content[ $ind_blockname ][ $blocksize ];
637
+            //link the current block to the block we just created
638
+            $this->currentBlock = &$this->content[ $ind_blockname ][ $blocksize ];
639
+        }
638 640
     }
639 641
 
640 642
     /**