News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Alternating rows background on the board index

Started by anunlike, October 05, 2005, 02:33:01 PM

Previous topic - Next topic

anunlike

for the board index - BoardIndex.template.php

change:
// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{
/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<tr class="windowbg2">


to:
// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{
/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
$alternate = false;
foreach ($category['boards'] as $board)
{
$alternate = !$alternate;
echo '
<tr class="windowbg', $alternate ? '2' : '', '">


'windowbg' = color of first row
'2' = windowbg2 = color of the next row


{edit: removed typo - Compuart}

.Darkman


Clever Tutorials - One place for all of them . . .
SMF Theme Works



fuddes

Is there a way to do this on the messageindex.php file too? I applied it in the same way but nothing happened.

codenaught

For the child boards or the display of the topics? I was working on a find and replace tutorial for the topic listing but then realized you might have meant the child boards.
Dev Consultant
Former SMF Doc Coordinator

fuddes

No, I meant the displaying of topics. You had it right.  :) I've been toying with the code for a while and just haven't been able to make it work.

xyxis_fahim

I'm not getting this clearly.

can anyone explain it via demo?
sry

codenaught

What's the first thing you don't understand? Do you know how to modify files? How do I modify files?

fuddes, if you see this, would you still like help with this?
Dev Consultant
Former SMF Doc Coordinator

xyxis_fahim

Quote from: akabugeyes on October 26, 2007, 09:10:25 PM
What's the first thing you don't understand? Do you know how to modify files? How do I modify files?

fuddes, if you see this, would you still like help with this?

No I meant like what exactly "Alternating rows background " means

codenaught

It will have it so that colors alternate with each row of boards shown.

Example:

---------------
Board Name (Blue)
---------------
Board Name (Green)
---------------
Board Name (Blue)
---------------
Board Name (Green)

Currently it alternates with column.
Dev Consultant
Former SMF Doc Coordinator

xyxis_fahim


falguni1


Fiery

Were you able to get everything working as you like?

DAB Empire

Looks like SMF 2.x has different code.  How can I add this to 2.x?

Arantor

Note that it will be theme dependent - your theme may have a custom BoardIndex.template.php - please post it here so we can look at it.
Holder of controversial views, all of which my own.

DAB Empire


Arantor

For the default template in RC1.2 (and note it'll be different in RC2): - just to alternate the main board background

// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{
$alternate = false;
echo '
<table cellspacing="1" class="bordercolor boardsframe">';

/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
$alternate = !$alternate;
echo '
<tr>
<td', !empty($board['children']) ? ' rowspan="2"' : '', ' class="windowbg icon">
<a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">';

// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url'], '/on', $board['new'] ? '' : '2', '.gif" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" border="0" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url'], '/redirect.gif" alt="*" title="*" border="0" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url'], '/off.gif" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';

echo '
</a>
</td>
<td class="windowbg', $alternate ? '2' : '', ' info">
Holder of controversial views, all of which my own.

DAB Empire

The code above worked... a little.  Had some columns that weren't included in the color changes.  It helped me understand what to change though.  Thanks.  Here is the updated version.

in BoardIndex.template.php

      // Assuming the category hasn't been collapsed...
      if (!$category['is_collapsed'])
      {
         $alternate = false;
         echo '
      <table cellspacing="1" class="bordercolor boardsframe">';

         /* Each board in each category's boards has:
         new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
         children (see below.), link_children (easier to use.), children_new (are they new?),
         topics (# of), posts (# of), link, href, and last_post. (see below.) */
         foreach ($category['boards'] as $board)
         {
            $alternate = !$alternate;
            echo '
         <tr>
            <td', !empty($board['children']) ? ' rowspan="2"' : '', ' class="windowbg', $alternate ? '2' : '', ' icon">
               <a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">';

            // If the board or children is new, show an indicator.
            if ($board['new'] || $board['children_new'])
               echo '
                  <img src="', $settings['images_url'], '/on', $board['new'] ? '' : '2', '.gif" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" border="0" />';
            // Is it a redirection board?
            elseif ($board['is_redirect'])
               echo '
                  <img src="', $settings['images_url'], '/redirect.gif" alt="*" title="*" border="0" />';
            // No new posts at all! The agony!!
            else
               echo '
                  <img src="', $settings['images_url'], '/off.gif" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';

            echo '
               </a>
            </td>
            <td class="windowbg', $alternate ? '2' : '', ' info">
<h4><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a>';

// Has it outstanding posts for approval?
if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
echo '
<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > $board['unapproved_posts'] ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';

echo '
</h4>
<p>', $board['description'] , '</p>';

// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
if (!empty($board['moderators']))
echo '
<p class="moderators">', count($board['moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';

// Show some basic information about the number of posts, etc.
echo '
</td>
<td', !empty($board['children']) ? ' rowspan="2"' : '', ' class="windowbg', $alternate ? '2' : '', ' stats smalltext">
', $board['posts'], ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], ' <br />
', $board['is_redirect'] ? '' : $board['topics'] . ' ' . $txt['board_topics'], '
</td>
<td', !empty($board['children']) ? ' rowspan="2"' : '', ' class="windowbg', $alternate ? '2' : '', ' smalltext lastpost">';

/* The board's and children's 'last_post's have:

Arantor

I just changed the code from the opening post - and I did say it was linked to the main board background, not to any of the other columns.
Holder of controversial views, all of which my own.

snowalker

I'd duplicate the default theme, named "whatevername", but it doesn't contain any BoardIndex.template.php file to modify it. Any help with this?

Arantor

Quote from: snowalker on March 17, 2010, 11:47:56 AM
I'd duplicate the default theme, named "whatevername", but it doesn't contain any BoardIndex.template.php file to modify it. Any help with this?

Copy the file from Themes/default to your theme. Basically what happens is that SMF will reuse files from the default theme if they're not present in a custom one.
Holder of controversial views, all of which my own.

Super_Benno

#20
does it work in the latest release?




Advertisement: