Skip to content

Commit d7a5917

Browse files
committed
Show SMF News
This adds a new configuration option for showing the SMF news on MediaWiki. Signed-off-by: Mustafa Can Elmacı <[email protected]>
1 parent 835f266 commit d7a5917

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,21 @@ $wgDefaultSkin = "smfcurve2";
4747
We provide a few simple and more advanced methods to customizing the skin.
4848

4949
### Simple
50-
51-
#### Adding the forum main menu
5250
Add to your LocalSettings.php (After your wfLoadSkin line)
51+
52+
#### Connecting to SMF SSI.
53+
Needed for adding the forum news and main menu.
5354
```
5455
$wgsmfRoot = '/path/to/forum';
56+
```
57+
58+
#### Adding the forum news
59+
```
60+
$wgshowSMFnews = true;
61+
```
62+
63+
#### Adding the forum main menu
64+
```
5565
$wgshowSMFmenu = true;
5666
```
5767

includes/smfCurve2Template.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class smfCurve2Template extends BaseTemplate
8383
/**
8484
* @var bool
8585
*/
86+
protected $showSMFnews = false;
8687
protected $showSMFmenu = false;
8788
protected $useLogoImage = false;
8889
protected $useSideSearchBox = false;
@@ -120,6 +121,11 @@ private function setupCustomization()
120121
require_once $ssi . '/SSI.php';
121122
}
122123

124+
// Add to your LocalSettings: $wgshowSMFnews = true;
125+
if (is_bool($this->getConfig()->get('showSMFnews'))) {
126+
$this->showSMFnews = $this->getConfig()->get('showSMFnews');
127+
}
128+
123129
// Add to your LocalSettings: $wgshowSMFmenu = true;
124130
if (is_bool($this->getConfig()->get('showSMFmenu'))) {
125131
$this->showSMFmenu = $this->getConfig()->get('showSMFmenu');
@@ -177,6 +183,9 @@ public function execute()
177183
<div id="upper_section">
178184
<div id="inner_section">';
179185

186+
// Show SMF News ?
187+
$this->smfNews();
188+
180189
// Do we have an SMF Menu ?
181190
$this->smfMenu();
182191

@@ -702,4 +711,31 @@ public function smfMenu()
702711
</div>';
703712
}
704713
}
714+
715+
/**
716+
* smfNews() --> Loads Forum News.
717+
*/
718+
public function smfNews()
719+
{
720+
global $context, $settings, $txt;
721+
722+
if ((defined('SMF') && $this->showSMFnews)) {
723+
echo'
724+
<div id="inner_wrap" class="hide_720">
725+
<div class="user">
726+
<time datetime="', smf_gmstrftime('%FT%TZ'), '">', $context['current_time'], '</time>
727+
</div>';
728+
729+
// Show a random news item? (or you could pick one from news_lines...)
730+
if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
731+
echo '
732+
<div class="news">
733+
<span>', $txt['news'], ': </span>
734+
<p>', $context['random_news_line'], '</p>
735+
</div>';
736+
737+
echo '
738+
</div>';
739+
}
740+
}
705741
}

resources/css/main.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,62 @@ h1.forumtitle a {
11881188
clear: both;
11891189
}
11901190

1191+
/* The upper_section, float the two each way */
1192+
#inner_wrap {
1193+
display: flex;
1194+
justify-content: space-between;
1195+
align-items: center;
1196+
border-bottom: 1px solid #bbb;
1197+
margin-bottom: 12px;
1198+
}
1199+
.user {
1200+
padding: 0 4px 8px 4px;
1201+
font-size: 0.9em;
1202+
white-space: nowrap;
1203+
}
1204+
.user:only-child {
1205+
width: 100%;
1206+
display: flex;
1207+
justify-content: space-between;
1208+
}
1209+
.user time,
1210+
.user .unread_links,
1211+
.user .unread_links li {
1212+
display: inline-block;
1213+
}
1214+
.user:not(:last-child) time:not(:last-child)::after,
1215+
.user .unread_links li:not(:last-child)::after {
1216+
content: " • ";
1217+
margin: 0 1ch;
1218+
}
1219+
ul li.greeting {
1220+
font-weight: bold;
1221+
}
1222+
/* The login form. */
1223+
#guest_form {
1224+
overflow: hidden;
1225+
font-size: 0.9em;
1226+
margin-left: -2px;
1227+
}
1228+
/* News section. */
1229+
#inner_wrap .news {
1230+
padding: 0 0 8px 1ch;
1231+
font-size: 0.9em;
1232+
display: flex;
1233+
align-items: baseline;
1234+
max-width: 50%;
1235+
}
1236+
#inner_wrap .news span {
1237+
font-weight: bold;
1238+
line-height: initial;
1239+
}
1240+
#inner_wrap .news span,
1241+
#inner_wrap .news p {
1242+
display: inline;
1243+
margin: 0;
1244+
padding-left: 1ch;
1245+
}
1246+
11911247
/* The content section */
11921248
#content_section {
11931249
margin: 0 auto;

resources/css/responsive.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@
122122
float:none;
123123
margin: 0;
124124
}
125+
/* Hide me */
126+
#inner_wrap.hide_720, #inner_wrap time, #inner_wrap .news {
127+
display: none !important;
128+
}
125129
}
126130

127131
/* 720 ---> 480 */

skin.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
"value": "",
129129
"description": "@var string Path to SMF Root, without the trailing slash (/). For us with showing the menu and/or logo."
130130
},
131+
"showSMFnews": {
132+
"value": false,
133+
"description": "@var boolean Show the SMF News."
134+
},
131135
"showSMFmenu": {
132136
"value": false,
133137
"description": "@var boolean Show the SMF Main Menu."

0 commit comments

Comments
 (0)