This extension enables the author filter feature by using the page’s author
property to add multiple routes, such as http://127.0.0.1/blog/author/:author/1
, to each page to allow users to list all pages in the current folder by author.
Usage
These HTML classes will be added to the root element if it contains a class
attribute when you are on the authors page. You can use this feature to create a specific look or response on your site from the client side if the following classes are found in the root element:
is:authors
- Will be added if the current items view is an authors view and is not empty.
Example usage in CSS code:
.is\:authors body {
border-top: 4px solid #f00;
}
Example usage in JS code:
if (document.documentElement.classList.contains('is:authors')) {
console.info('You are currently in the authors page.');
}
These additional conditional statements are available for use in layouts to show/hide elements on your site from the server side:
$site->is('authors')
- Returns
true
if the current items view is an authors view and is not empty.
Example usage in HTML/PHP code:
<?php if ($site->is('authors')): ?>
<p role="alert">
<?= i('You are currently in the authors page.'); ?>
</p>
<?php endif; ?>
These additional variables are available for use in layouts that carry data related to the currently active authors page:
$author
- This variable is an instance of the
User
class, which you can use to get the current author information.
Example usage in HTML/PHP code:
<?php if ($site->is('authors') && !empty($author)): ?>
<p role="alert">
<?= i('Showing list of articles written by %s.', (string) $author); ?>
</p>
<?php endif; ?>
0 Comments
No comments yet.