Displaying Page Author with Simple Pages

Is there a ready-made hack or a code snippet for getting Simple Pages to display the author of a page automatically as part of the page content?

Thanks in advance.

You can override the display for simple pages the same way as for anything else in a theme: you copy the "base" file into the theme and change it.

In this case, you'd copy SimplePages' views/public/page/show.php to simple-pages/page/show.php in your theme.

Printing the author is an easy addition:

echo metadata('simple_pages_page', 'created_username');

Thanks John!

John, just one follow-up: What about displaying the real name (i.e., the "Display Name") instead of the username?

That's not quite as direct, but still pretty easy:


$page = get_current_record('simple_pages_page');
$user = $page->getCreatedByUser();
echo metadata($user, 'name'); 


Awesome. Worked perfectly. Thanks Patrick!

No problem! Might also be worth noting that $page also has a getModifiedByUser() method, which might or might not be part of what you want to display.