# Problem with extending page model

**URL:** <https://forum.getkirby.com/t/problem-with-extending-page-model/34131>\
**Category:** Questions\
**Tags:** v4\
**Created:** [May 23, 2025, 10:33am UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131 "2025-05-23T10:33:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhueck](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@nhueck](https://forum.getkirby.com/u/nhueck)\
**Post date:** [May 23, 2025, 10:33am UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131/1 "2025-05-23T10:33:30Z")

</div>

Hi,  
for reporting purposes I wrote a module extending the Page class.  
In this simplified example I want to display the title of the most recent blog article in the “Predigten” folder.

```auto
class StatisticsPage extends Page
{
	
  	public function reports(): array
  	{

		$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();
			
		return [
			[
				'label' => 'Test',
				'value' => $letzteSeiteName,
			]
    	];
  	}
}

```

The problem occurs, when I use the line

```auto
$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();

```

then the report is just empty.  
When I replace this line with

```auto
$letzteSeiteName = "Expample"

```

the report shows “Test: Example” as expected.

The very same line

```auto
$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();

```

works in normal page templates just fine.

What’s going on? Can anybody please explain?  
Thanks,  
Nikolaus

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 23, 2025, 1:20pm UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131/2 "2025-05-23T13:20:45Z")

</div>

> [@nhueck](#):
>
> What’s going on? Can anybody please explain?

Use `$this->site()->find()…`

$site is not defined in that context.

---

<div class="post-metadata">

**Author:** ![nhueck](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@nhueck](https://forum.getkirby.com/u/nhueck)\
**Post date:** [May 25, 2025, 8:48am UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131/3 "2025-05-25T08:48:02Z")

</div>

Thanks for your quick reply.  
But this does not seem to help in my case.

To simplify things, I tried:

```auto
<?php
	class StatisticsPage extends Page
	{
  		public function reports(): array
  		{
			$letzteSeiteURL = $this->$site()->url();
			
			return [
				[
					'label' => 'Test',
					'value' => $letzteSeiteURL,
				]
    		];
  		}
	}
?>

```

Still no success.  
Any ideas?

Nikolaus

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 25, 2025, 9:17am UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131/4 "2025-05-25T09:17:24Z")

</div>

> [@nhueck](#):
>
> ` $letzteSeiteURL = $this->$site()->url();`

Not `$this->$site()` but `$this->site()` without the Dollar sign!

---

<div class="post-metadata">

**Author:** ![nhueck](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@nhueck](https://forum.getkirby.com/u/nhueck)\
**Post date:** [May 25, 2025, 9:32am UTC](https://forum.getkirby.com/t/problem-with-extending-page-model/34131/5 "2025-05-25T09:32:14Z")

</div>

Sorry, yes, of course, that works.  
Thanks again!
