Difference between revisions of "Extensions:News Widget"

From Lorekeeper Wiki
Jump to navigation Jump to search
(Creation of the news widget extension...!)
Tag: 2017 source edit
 
m (Formatting and adding images)
Tag: 2017 source edit
 
Line 1: Line 1:
 
{{Extensioninfobox|title=News Widget|desc=A widget that displays the most recent news.|auth=Min|status=Stable|github={{Github|user=liwoyadan|branch=ext/news-widget}}|LKVer=2.1.0|migration=no|package=no}}
 
{{Extensioninfobox|title=News Widget|desc=A widget that displays the most recent news.|auth=Min|status=Stable|github={{Github|user=liwoyadan|branch=ext/news-widget}}|LKVer=2.1.0|migration=no|package=no}}
 
<!-- Put a short summary of your extension here! -->
 
<!-- Put a short summary of your extension here! -->
A small extension. Displays a widget on the logged-in dashboard that will show the most recently created/updated news and optionally a truncated text preview. By default the widget displays the two most recent news but can be configured for more. The widget is called with <code>@include('widgets._news', ['textPreview' => true])</code> and can be used elsewhere (i.e. in a sidebar) as long as the <code>$newses</code> variable is declared on respective pages.
+
A small extension. Displays a widget on the logged-in dashboard that will show the most recently created/updated news and optionally a truncated text preview. By default the widget displays the two most recent news but can be configured for more.  
 +
 
 +
The widget is called with <code>@include('widgets._news', ['textPreview' => true])</code> and can be used elsewhere (i.e. in a sidebar) as long as the <code>$newses</code> variable is declared on respective pages.
 
== Installation ==
 
== Installation ==
 
<!-- Describe installation. Include any requirements (such as packages), necessary commands, etc. -->
 
<!-- Describe installation. Include any requirements (such as packages), necessary commands, etc. -->
Line 9: Line 11:
 
<!-- Is any configuration necessary? Describe it here! -->
 
<!-- Is any configuration necessary? Describe it here! -->
 
Setting the 'textPreview' variable to true will show a 300 character long preview of the respective news along with a read more link at the end. Setting it to false will only display the title, posting, and editing date of the news.
 
Setting the 'textPreview' variable to true will show a 300 character long preview of the respective news along with a read more link at the end. Setting it to false will only display the title, posting, and editing date of the news.
 +
 
To configure how many news are displayed, in <code>app\Http\Controllers\HomeController.php</code> in the first function in the file edit the '2' in <code>'newses' => News::visible()->orderBy('updated_at', 'DESC')->take(2)->get(),</code> to however many news you'd like to be displayed.
 
To configure how many news are displayed, in <code>app\Http\Controllers\HomeController.php</code> in the first function in the file edit the '2' in <code>'newses' => News::visible()->orderBy('updated_at', 'DESC')->take(2)->get(),</code> to however many news you'd like to be displayed.
 
The widget itself can be edited and styled in <code>resources\views\widgets\_news.blade.php</code>.
 
The widget itself can be edited and styled in <code>resources\views\widgets\_news.blade.php</code>.
Line 15: Line 18:
 
== Images ==
 
== Images ==
 
<gallery>
 
<gallery>
 +
File:TextPreview true.png|alt=A Lorekeeper dashboard with a widget titled 'Recent News', displaying two recent news along with their posting date and a text preview.|The news widget on the dashboard displaying the two most recent news along with a truncated text preview.
 +
File:TextPreview false.png|alt=A Lorekeeper dashboard with a widget titled 'Recent News', displaying two recent news along with their posting date.|The news widget only displaying the news title and posting date, with no text preview.
 
</gallery>
 
</gallery>
 
== Troubleshooting ==
 
== Troubleshooting ==

Latest revision as of 17:31, 28 September 2023

News Widget
Description A widget that displays the most recent news.
Author(s) Min
Status Stable
Github ext/news-widget
LK Version 2.1.0






A small extension. Displays a widget on the logged-in dashboard that will show the most recently created/updated news and optionally a truncated text preview. By default the widget displays the two most recent news but can be configured for more.

The widget is called with @include('widgets._news', ['textPreview' => true]) and can be used elsewhere (i.e. in a sidebar) as long as the $newses variable is declared on respective pages.

Installation

Pull the branch; resolve any conflicts if necessary and run php artisan update-extension-tracker. There are no migrations in this extension.

Configuration

Setting the 'textPreview' variable to true will show a 300 character long preview of the respective news along with a read more link at the end. Setting it to false will only display the title, posting, and editing date of the news.

To configure how many news are displayed, in app\Http\Controllers\HomeController.php in the first function in the file edit the '2' in 'newses' => News::visible()->orderBy('updated_at', 'DESC')->take(2)->get(), to however many news you'd like to be displayed. The widget itself can be edited and styled in resources\views\widgets\_news.blade.php.

Usage

Images

Troubleshooting

I can be found in the Lorekeeper server!

See Also