Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 73 additions & 146 deletions docs/events.md
Original file line number Diff line number Diff line change
@@ -1,160 +1,87 @@
# Available php Events
# Events

The PHP and template events keep the names they had in `nickvergessen/newspage`,
so listeners and style templates written for it keep working.
Other extensions can add code or HTML to the news page through these events, without editing NV Newspage.

The events from the original extension keep their `nickvergessen` names, so listeners and style templates written for `nickvergessen/newspage` keep working. Events added since use `phpbbmodders_newspage`.

## PHP events

### nickvergessen.newspage.newspage
* Locations:
+ controller/main.php
* Location: `controller/main.php`
* Variables:
+ `forum_id` - Forum ID of the category to display
+ `year` - Limit the news to a certain year
+ `month` - Limit the news to a certain month
+ `page` - Page to display
* Since: 1.2
* Purpose: You can use this event to load settings on the newspage
* Purpose: Runs before the news list is built. Use it to load settings or language for the news page, or to change which news is shown.

### nickvergessen.newspage.single_news
* Locations:
+ controller/main.php
* Location: `controller/main.php`
* Variables:
+ `topic_id` - Topic ID of the news to display
* Since: 1.2
* Purpose: You can use this event to load settings on a single page view of the
newspage


# Available Template Events

### nickvergessen_newspage_after
* Locations:
+ styles/prosilver/template/newspage_body.html
* Since: 1.2
* Purpose: Add content after the output of the newspage

### nickvergessen_newspage_before
* Locations:
+ styles/prosilver/template/newspage_body.html
* Since: 1.2
* Purpose: Add content before the output of the newspage

### nickvergessen_newspage_filters_after
* Locations:
+ styles/prosilver/template/newspage_body.html
* Since: 1.2
* Purpose: Add content after the list of filters

### nickvergessen_newspage_filters_before
* Locations:
+ styles/prosilver/template/newspage_body.html
* Since: 1.2
* Purpose: Add content before the list of filters

### nickvergessen_newspage_title_after
* Locations:
+ styles/prosilver/template/newspage_body.html
* Since: 1.2
* Purpose: Add content after the title of the newspage
For before event use `### nickvergessen_newspage_before`

### viewtopic_body_avatar_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_avatar_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_contact_fields_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_contact_fields_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_post_author_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_post_author_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_post_buttons_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_post_buttons_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_custom_fields_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_custom_fields_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_content_footer
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_details_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_details_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_notices_after
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html

### viewtopic_body_postrow_post_notices_before
* Locations:
+ styles/prosilver/template/viewtopic_postrow.html
* Since: 1.2
* Purpose: Copy the respective event from phpBB's viewtopic_body.html
* Purpose: Runs before a single news item is shown. Use it to load settings or language for that page.

## Template events

A style or extension uses a template event by adding `styles/<style>/template/event/<event name>.html`.

### News page

All in `styles/prosilver/template/newspage_body.html`.

| Event | Since | Where |
|---|---|---|
| `nickvergessen_newspage_before` | 1.2 | Top of the news page, before the heading |
| `phpbbmodders_newspage_single_before` | 1.4.0 | Single news item only: above the "All news" link and the heading |
| `nickvergessen_newspage_title_after` | 1.2 | Right after the heading |
| `nickvergessen_newspage_filters_before` | 1.2 | Before the filter bar |
| `phpbbmodders_newspage_active_filters_append` | 1.4.0 | At the end of the "Showing" line, after the filter chips; only shown while a filter is active |
| `nickvergessen_newspage_filters_after` | 1.2 | After the filter bar and the "Showing" line |
| `phpbbmodders_newspage_single_after` | 1.4.0 | Single news item only: after the news item |
| `nickvergessen_newspage_after` | 1.2 | Bottom of the news page |

The filter bar and the "Showing" line aren't shown on a single news item, so the filter events don't fire there.

### Each news item

All in `styles/prosilver/template/viewtopic_postrow.html`, inside the `postrow` loop, so `postrow.*` variables are available. The `viewtopic_body_*` events have the same names and roughly the same places as in phpBB's `viewtopic_body.html`, so an extension that adds something to forum posts usually shows up on the news page too.

| Event | Since | Where |
|---|---|---|
| `viewtopic_body_postrow_post_before` | 1.2 | Before the news item |
| `viewtopic_body_post_buttons_list_before` | 1.4.0 | Before the post buttons (whether or not they're shown) |
| `viewtopic_body_post_buttons_before` | 1.2 | Inside the post buttons list, before the first button |
| `viewtopic_body_post_buttons_after` | 1.2 | Inside the post buttons list, after the last button |
| `viewtopic_body_post_buttons_list_after` | 1.4.0 | After the post buttons (whether or not they're shown) |
| `viewtopic_body_post_subject_before` | 1.4.0 | Before the title; not on a single news item, where the page heading is the title |
| `viewtopic_body_postrow_post_details_before` | 1.2 | Before the byline |
| `viewtopic_body_avatar_before` | 1.2 | Before the avatar in the byline; only with "Show user information" on and an avatar |
| `viewtopic_body_avatar_after` | 1.2 | After the avatar in the byline; same condition |
| `viewtopic_body_post_author_before` | 1.2 | Before the author's name in the byline |
| `viewtopic_body_post_author_after` | 1.2 | After the author's name in the byline |
| `phpbbmodders_newspage_byline_append` | 1.4.0 | At the end of the byline, after the date and forum |
| `viewtopic_body_postrow_rank_before` | 1.4.0 | Before the rank in the poster line; only with "Show user information" on |
| `viewtopic_body_postrow_rank_after` | 1.4.0 | After the rank in the poster line; same condition |
| `viewtopic_body_postrow_custom_fields_before` | 1.2 | Before the profile fields in the poster line; same condition |
| `viewtopic_body_postrow_custom_fields_after` | 1.2 | After the profile fields in the poster line; same condition |
| `viewtopic_body_postrow_post_details_after` | 1.2 | After the byline and poster line |
| `phpbbmodders_newspage_lead_image_before` | 1.4.0 | Before the lead image; only when one is shown |
| `phpbbmodders_newspage_lead_image_after` | 1.4.0 | After the lead image; same condition |
| `viewtopic_body_postrow_content_before` | 1.4.0 | Before the news text |
| `viewtopic_body_postrow_content_after` | 1.4.0 | After the news text |
| `viewtopic_body_postrow_post_notices_before` | 1.2 | Before the notices (poll, download notice, edited or deleted message) |
| `viewtopic_body_postrow_post_notices_after` | 1.2 | After the notices |
| `viewtopic_body_postrow_signature_before` | 1.4.0 | Before the signature (whether or not one is shown) |
| `viewtopic_body_postrow_signature_after` | 1.4.0 | After the signature (whether or not one is shown) |
| `viewtopic_body_postrow_post_content_footer` | 1.2 | Before the footer line |
| `phpbbmodders_newspage_footer_prepend` | 1.4.0 | At the start of the footer line, before "Read more" and the comment count |
| `phpbbmodders_newspage_footer_append` | 1.4.0 | In the footer line, after "View topic" and before the back-to-top arrow; a good place for share or like links |
| `viewtopic_body_postrow_back2top_before` | 1.4.0 | In the footer line, before the back-to-top arrow's block |
| `viewtopic_body_postrow_back2top_prepend` | 1.4.0 | Inside the back-to-top block, before the arrow |
| `viewtopic_body_postrow_back2top_append` | 1.4.0 | Inside the back-to-top block, after the arrow |
| `viewtopic_body_postrow_back2top_after` | 1.4.0 | In the footer line, after the back-to-top arrow's block |
| `viewtopic_body_postrow_post_after` | 1.2 | After the news item |

phpBB's contact-menu events (`viewtopic_body_contact_fields_*`, `viewtopic_body_contact_icon_*`) and Who is online events (`viewtopic_body_online_list_*`) aren't used: the news page has no contact menu or online list.
8 changes: 8 additions & 0 deletions styles/prosilver/template/newspage_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

<!-- EVENT nickvergessen_newspage_before -->

<!-- IF NEWS_ONLY -->
<!-- EVENT phpbbmodders_newspage_single_before -->
<!-- ENDIF -->
<!-- IF NEWS_ONLY and U_NEWSPAGE -->
<p class="newspage-back"><a href="{U_NEWSPAGE}"><i class="icon fa-arrow-left fas fa-fw" aria-hidden="true"></i>{L_NEWS_ALL}</a></p>
<!-- ENDIF -->
Expand Down Expand Up @@ -38,6 +41,7 @@
<!-- IF NEWS_FILTER_CATEGORY and NEWS_FILTER_ARCHIVE_YEAR -->
<a href="{U_NEWSPAGE}" class="newspage-clear">{L_NEWS_FILTER_CLEAR}</a>
<!-- ENDIF -->
<!-- EVENT phpbbmodders_newspage_active_filters_append -->
</p>
<!-- ENDIF -->
<!-- EVENT nickvergessen_newspage_filters_after -->
Expand All @@ -63,6 +67,10 @@
<br />
<!-- ENDIF -->

<!-- IF NEWS_ONLY -->
<!-- EVENT phpbbmodders_newspage_single_after -->
<!-- ENDIF -->

<!-- EVENT nickvergessen_newspage_after -->

<!-- INCLUDE overall_footer.html -->
22 changes: 21 additions & 1 deletion styles/prosilver/template/viewtopic_postrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- EVENT viewtopic_body_postrow_post_before -->
<article id="p{postrow.POST_ID}" class="newspage-item<!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_POST_DELETED --> deleted<!-- ENDIF -->">
<header class="newspage-item-header">
<!-- EVENT viewtopic_body_post_buttons_list_before -->
<!-- IF not S_IS_BOT and NEWS_POST_BUTTONS -->
<!-- IF postrow.U_EDIT or postrow.U_DELETE or postrow.U_REPORT or postrow.U_WARN or postrow.U_INFO or postrow.U_QUOTE -->
<ul class="post-buttons">
Expand Down Expand Up @@ -40,8 +41,10 @@
</ul>
<!-- ENDIF -->
<!-- ENDIF -->
<!-- EVENT viewtopic_body_post_buttons_list_after -->

<!-- IF not NEWS_ONLY -->
<!-- EVENT viewtopic_body_post_subject_before -->
<h3 class="newspage-item-title"><!-- IF postrow.POST_ICON_IMG --><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" /> <!-- ENDIF --><a href="<!-- IF NEWS_ONLY -->#p{postrow.POST_ID}<!-- ELSE -->{postrow.U_NEWS}<!-- ENDIF -->">{postrow.POST_SUBJECT}</a></h3>
<!-- ENDIF -->

Expand All @@ -61,11 +64,14 @@ <h3 class="newspage-item-title"><!-- IF postrow.POST_ICON_IMG --><img src="{T_IC
<span class="newspage-separator" aria-hidden="true">&middot;</span>
<span class="newspage-forum">{{ lang('NEWS_IN_FORUM', '<a href="' ~ postrow.U_NEWS_FORUM ~ '">' ~ postrow.NEWS_FORUM_NAME ~ '</a>') }}</span>
<!-- ENDIF -->
<!-- EVENT phpbbmodders_newspage_byline_append -->
</p>

<!-- IF NEWS_USER_INFO -->
<p class="newspage-poster">
<!-- EVENT viewtopic_body_postrow_rank_before -->
<!-- IF postrow.RANK_TITLE or postrow.RANK_IMG --><span class="newspage-rank">{postrow.RANK_IMG} {postrow.RANK_TITLE}</span><!-- ENDIF -->
<!-- EVENT viewtopic_body_postrow_rank_after -->
<!-- IF postrow.POSTER_POSTS != '' --><span><strong>{L_POSTS}{L_COLON}</strong> <!-- IF postrow.U_SEARCH !== '' --><a href="{postrow.U_SEARCH}"><!-- ENDIF -->{postrow.POSTER_POSTS}<!-- IF postrow.U_SEARCH !== '' --></a><!-- ENDIF --></span><!-- ENDIF -->
<!-- IF postrow.POSTER_WARNINGS --><span><strong>{L_WARNINGS}{L_COLON}</strong> {postrow.POSTER_WARNINGS}</span><!-- ENDIF -->
<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
Expand Down Expand Up @@ -109,9 +115,13 @@ <h3 class="newspage-item-title"><!-- IF postrow.POST_ICON_IMG --><img src="{T_IC
<!-- ENDIF -->

<!-- IF postrow.NEWS_LEAD_IMAGE_SRC -->
<!-- EVENT phpbbmodders_newspage_lead_image_before -->
<a href="{postrow.U_NEWS}" class="newspage-lead-image"><img src="{postrow.NEWS_LEAD_IMAGE_SRC}" alt="{postrow.NEWS_LEAD_IMAGE_ALT}" loading="lazy" /></a>
<!-- EVENT phpbbmodders_newspage_lead_image_after -->
<!-- ENDIF -->
<!-- EVENT viewtopic_body_postrow_content_before -->
<div class="content">{postrow.MESSAGE}</div>
<!-- EVENT viewtopic_body_postrow_content_after -->

<!-- IF postrow.S_HAS_ATTACHMENTS -->
<dl class="attachbox">
Expand Down Expand Up @@ -142,10 +152,13 @@ <h3 class="newspage-item-title"><!-- IF postrow.POST_ICON_IMG --><img src="{T_IC
<!-- ENDIF -->
<!-- IF postrow.BUMPED_MESSAGE --><div class="notice">{postrow.BUMPED_MESSAGE}</div><!-- ENDIF -->
<!-- EVENT viewtopic_body_postrow_post_notices_after -->
<!-- EVENT viewtopic_body_postrow_signature_before -->
<!-- IF NEWS_USER_INFO and postrow.SIGNATURE --><div id="sig{postrow.POST_ID}" class="signature">{postrow.SIGNATURE}</div><!-- ENDIF -->
<!-- EVENT viewtopic_body_postrow_signature_after -->

<!-- EVENT viewtopic_body_postrow_post_content_footer -->
<footer class="newspage-item-footer">
<!-- EVENT phpbbmodders_newspage_footer_prepend -->
<!-- IF not NEWS_ONLY and postrow.S_NEWS_SHORTENED -->
<a href="{postrow.U_NEWS}" class="newspage-read-more">{L_NEWS_READ_MORE} <i class="icon fa-arrow-right fas fa-fw" aria-hidden="true"></i></a>
<!-- ENDIF -->
Expand All @@ -154,7 +167,14 @@ <h3 class="newspage-item-title"><!-- IF postrow.POST_ICON_IMG --><img src="{T_IC
<a href="{postrow.U_NEWS_REPLY}" class="newspage-reply"><i class="icon fa-reply fas fa-fw" aria-hidden="true"></i>{L_NEWS_REPLY}</a>
<!-- ENDIF -->
<a href="{postrow.U_MINI_POST}" class="newspage-view-topic">{L_NEWS_VIEW_TOPIC}</a>
<a href="#top" class="newspage-top top" title="{L_BACK_TO_TOP}"><i class="icon fa-chevron-circle-up fas fa-fw" aria-hidden="true"></i><span class="sr-only">{L_BACK_TO_TOP}</span></a>
<!-- EVENT phpbbmodders_newspage_footer_append -->
<!-- EVENT viewtopic_body_postrow_back2top_before -->
<span class="newspage-top back2top">
<!-- EVENT viewtopic_body_postrow_back2top_prepend -->
<a href="#top" class="top" title="{L_BACK_TO_TOP}"><i class="icon fa-chevron-circle-up fas fa-fw" aria-hidden="true"></i><span class="sr-only">{L_BACK_TO_TOP}</span></a>
<!-- EVENT viewtopic_body_postrow_back2top_append -->
</span>
<!-- EVENT viewtopic_body_postrow_back2top_after -->
</footer>
</article>
<!-- EVENT viewtopic_body_postrow_post_after -->
Expand Down
16 changes: 15 additions & 1 deletion styles/prosilver/theme/newspage.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,25 @@
}

.newspage-item-footer .newspage-top {
color: #8f8f8f;
float: none;
font-size: 1.3em;
margin-left: auto;
}

.newspage-item-footer .newspage-top a {
color: #8f8f8f;
}

/* prosilver floats its back-to-top link; in the footer line it sits at the end */
.newspage-item-footer .back2top {
clear: none;
}

.newspage-item-footer .back2top .top {
float: none;
margin: 0;
}

@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
.newspage-item .post-buttons {
float: none;
Expand Down
Loading