News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

View Only Boards

Started by Rudolf, January 31, 2007, 10:45:10 AM

Previous topic - Next topic

AllMassive


fmofmpls

Quote from: Rudolf on November 29, 2007, 03:15:53 PM
Hiding those fields from the board index is mostly a template change. I will soon revisit the mod to make it more site-wide (including he Info-Center) and easier to show/hide stuff in the templates.

Great! Really look forward to it! Thanks for improving upon an already great mod!

Rudolf

Quote from: fmofmpls on November 29, 2007, 03:24:36 PM
Great! Really look forward to it! Thanks for improving upon an already great mod!

In the mean time you can hide fields on the index by using the $board['last_post']['protected'] variable. The name is misleading, it actually means that the board is view only.

Your theme seems different so I can't tell you exactly what to change but I can show you how it's done on the default theme as an example.
In BoardIndex.template.php you need to replace

<td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
', $board['posts'], ' ', $txt[21], ' <br />
', $board['topics'],' ', $txt[330], '
</span></td>

with
<td class="windowbg" valign="middle" align="center" style="width: 12ex;">', !$board['last_post']['protected']  ? '<span class="smalltext">
'. $board['posts']. ' '. $txt[21]. ' <br />
'. $board['topics'].' '. $txt[330]. '
</span>' : '<span class="vob_protected">' . $txt['vob_protected'] . '</span>' ,'</td>


The basic idea is to replace the text you want to hide with
<?php //ignore this line

!$board['last_post']['protected']  ? 'text to replace' 'here the strings have to be' 'concatendated using dots not commas' '<span class="vob_protected">' $txt['vob_protected'] . '</span>'

The text after the ? is the thing that will be hidden, while the text after : is the text you want to be show in it's place (you can leave it empty, using only '')
Note: I'm explaining in such layman's terms, because I don't know how much you know about php, or the ?: operator. If you know how to use it just ignore my explanation

If the text is part of a larger echo string then you have to "break out" of the string, as in the below example:
echo 'some view_only text';
Becomes
echo 'some ' , !$board['last_post']['protected'] ? 'view_only' : 'protected' , ' text';

Hope it helps.
If you still have problems post the piece of code with the bits you want to hide and I'll take a look at it.

The new version will be like this one, only with a more suggestive name for the variable and more widely available. Since this part is mostly template based and themes tend to be different I tend to keep the theme changes to the minimum in the mods.

In this particular mod it's quite easy (and hopefully it will be even easier) to customize themes to use this mod's features.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

AllMassive

hi - i've found some of these Error-MSGs in my Log:
8: Undefined index: protected
Datei: /forum/Themes/default/MessageIndex.template.php (main sub template - eval?)
Zeile: 64
8: Undefined index: protected
Datei: /forum/Themes/default/MessageIndex.template.php (main sub template - eval?)
Zeile: 63


My Line 63+64:

<b>', $txt[22], '</b> ', $txt[525], ' ', $board['last_post']['protected'] ? '<span class="vob_protected">' . $txt['vob_protected'] . '</span>' : $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['protected'] ? '<span class="vob_protected">' . $txt['vob_protected'] . '</span>' : $board['last_post']['link'], '<br />


These errors show up if regular Users joins a Board which has hidden Sub-Boards to Guests (Guests have no rights to view them at all). But those regulars Users are allowed to view those Subforums.

Rudolf

Do you have some boards that don't have posts in them?
I'm afraid you will have to wait for the next version to really fx that. Should take less then a week.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

AllMassive

No - there are posts in every Subforum - its no big deal, because the users are able to view it.

I just wanted to report that error.

Rudolf

I updated the mod.

I left the post count of the boards untouched. To hide it apply this change:

<td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
', $board['posts'], ' ', $txt[21], ' <br />
', $board['topics'],' ', $txt[330], '
</span></td>

with
<td class="windowbg" valign="middle" align="center" style="width: 12ex;">', !$board['protected']  ? '<span class="smalltext">
'. $board['posts']. ' '. $txt[21]. ' <br />
'. $board['topics'].' '. $txt[330]. '
</span>' : '<span class="vob_protected">' . $txt['vob_protected'] . '</span>' ,'</td>

The drill is like before, only that you use $board['protected'] instead of $board['last_post']['protected']

You can also add a different icon for the boards that are protected
Code (Search) Select
// If the board is new, show a strong indicator.
if ($board['new'])
echo '<img src="', $settings['images_url'], '/on.gif" alt="', $txt[333], '" title="', $txt[333], '" />';

Code (Add before) Select
if ($board['protected'])
echo '<img src="', $settings['images_url'], '/off2.gif" alt="', $txt[333], '" title="', $txt[333], '" />';
else

You will have to create the image call it off2.gif and place it in yout theme's images directory.

Both changes (posts/topic display and the board icon) have to be applied in both BoardIndex.template.php and MessageIndex.template.php (this later one for the sub boards).

I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

redline7366

A lot of great effort here Rudolf.  Thanks.

I would like to either show just the word "Protected" for the view only users or the last post/user/time info.

Here is my code in the two templates:



if (!empty($board['last_post']['id']))
echo '
', $txt[22], ' ', $txt[30], ' ', $board['last_post']['time'], '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], ' ', $txt[525], ' ', $board['last_post']['member']['link'];

echo '



What do I need to change it to in order to make it work?  Thanks!!

Rudolf

Something like this:

if (!empty($board['last_post']['id']))
echo !$empty($board['last_post']['protected']) ? '<span class="vob_protected">' . $txt['vob_protected'] . '<span>' : '
'. $txt[22]. ' '. $txt[30]. ' '. $board['last_post']['time']. '<br />
'. $txt['smf88']. ' '. $board['last_post']['link']. ' '. $txt[525]. ' '. $board['last_post']['member']['link'];

echo '
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

redline7366

Thanks Rudolf.  I think we're almost there.  When I place your code in the two templates I get a fatal error after the first board of the index shows.  So instead of saying "Protected" or last post/user/time info, it says:

Fatal error: Call to undefined function: () in ../../Sources/Load.php(1752) : eval()'d code on line 204


Any ideas on this?

Rudolf

I don't see why it should give you that error.
What you have around the line 204 in BoardIndex.template.php?
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

AllMassive

Thank you very much - nice Idea with the Protected-Colored-Link and the removal of the Links  :-*
Works fine on smf 1.1.4.

Rudolf

They are still links, only that the cursor doesn't changes into the hand.
You can change how the boards and posts appear in the style.css of your theme. Change color, background, font-size, family, weight etc.
Some CSS knowledge is required.
Code (CSS) Select

/* You can customize here the appearence of the protected areas */
.vob_protected
{
cursor: default;
}

.vob_protected, .vob_protected a:link, .vob_protected a:visited, .vob_protected a:hover
{
color: #666;
color: red;
text-decoration: none;
cursor: default;
}
/* //-View Only Boards MOD- END */


Personally I would put some less contrasting color. Depending on the theme I would put something that doesn't emphasizes those posts.
I've put red as default, because people wouldn't have noticed it. ;)
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Rudolf

@redline, here's the correct code to use. (There was an extra $ sign)

if (!empty($board['last_post']['id']))
echo !empty($board['last_post']['protected']) ? '<span class="vob_protected">' . $txt['vob_protected'] . '<span>' : '
'. $txt[22]. ' '. $txt[30]. ' '. $board['last_post']['time']. '<br />
'. $txt['smf88']. ' '. $board['last_post']['link']. ' '. $txt[525]. ' '. $board['last_post']['member']['link'];

echo '
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

redline7366


AllMassive

Please correct me if I'm wrong, but it seems like its possible for guests to read the rss-news - even on boards with no Guest-Access .

Rudolf

With the new way I handle the visibility of the boards, I expected something like this to happen.
I updated the mod package to disable the rss feeds and the search.

Anyway, this gave me an idea to implement. I'll look at it tonight.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

AllMassive


Manu.G

Since the upgrade to 1.1.4 I get all the time this error message in the error log:

Quote8: Undefined index: protected
Fichier: /..../...../...../...../forum/Themes/default/MessageIndex.template.php (eval?)
Line: 78

8: Undefined index: protected
Fichier: /..../...../...../...../forum/Themes/default/MessageIndex.template.php (eval?)
Line: 77

What's wrong there?
Version SMF 2.0.8
SimplePortal 2.3.5

Rudolf

Can you post what on lines 70-85 of your MessageIndex.temlate.php?
Are you sure that the changes in the Sources/MessagesIndex.php file were applied?
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Advertisement: