Panel pages modified by users

Hi
I come back to a previous post from here, I’ve set up a custom panel field to show the historic of modified pages. The problem is that each users can only see their own modifications. My goal is now to show every modified pages from every users. Can I do that without Database, and how ?

This is the actual code :

<?php

Kirby::plugin('medienbaecker/history', [
	'sections' => [
		'history' => [
			'props' => [
				'headline' => function($headline = "History") {
					return $headline;
				},
				'limit' => function($limit = 5) {
					return $limit;
				}
			],
			'computed' => [
				'latestPages' => function() {
					$latestPages = array();
					foreach(site()->index()->sortBy('modified', 'desc')->limit($this->limit()) as $latestPage) {
						$latestPages[] = [
							'title' => $latestPage->title()->value(),
							'link' => $latestPage->panelUrl(),
                            'last' => $latestPage->modified('d/m/y  H:i'),
                            'user' => kirby()->user()->name()->value(),
						];
					}
					return $latestPages;
				}
			]
		]
	]
]);

I don’t really see why this should only display modifications made by the current user. According to the code, you display the last x modified pages and then attach the current user to this information, no matter who actually modified a page, because that information does not exist.

And indeed, if you want to get the information who actually last modified a page, then you first have to store this information somewhere, either with each page via hooks, or in an external data base).

Yes you right, and if I want to store this information in a csv file for example, how to make this hooks ?

I found these lines that could help but don’t how to permute :

Kirby::plugin('mypage/historyhooks', [
    	'hooks' => [
            'page.update:after' => function ($newPage, $oldPage) {

            	$lasteditedpages = Db::insert('lasteditedpages', [
    	        	'user' => kirby()->user()->email(),
    	        	'title' => $newPage->title(),
    	        	'image' => $imageUrl,
    	        	'link' => $newPage->panelUrl(),
    	        ]);        	

            }
        ]
    ]);

This code would store the information in a database. For this to work, however, you first have to set up your database.

I’m not really sure what sort of changes $page->modified() actually catches.

Depending on what you want to store in your csv file (which will then be your source of truth for the section, I guess), you might have to use multiple hooks, because page.update:after only catches actual changes to the content, but not changes to the title, slug, status, sorting etc.

Ok, I think I will combine the solution from this topic Simple changelog hook for Kirby with this one Kirby 3 Panel - last edited pages

One last question : how to make a link on a specific tab from this custom historic panel ? I would like to click on the link to show directly the tab of the page containing the changelog (called #historique) ?

I’ve set this but the link don’t show directly the tab of the page

<a v-for="page in latestPages" :href="page.link#historique"><span aria-hidden="true" data-back="pattern" class="k-icon k-icon-circle-filled"><svg viewBox="0 0 16 16" style="color: rgb(197, 201, 198);"><use xlink:href="#icon-circle-filled"></use></svg></span><span>{{ page.title }}</span><div>{{ page.user }}</div><div>{{ page.last }}</div></a>