Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: anunlike on October 05, 2005, 02:33:01 PM

Title: Alternating rows background on the board index
Post by: anunlike on October 05, 2005, 02:33:01 PM
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}
Title: Re: Alternating rows background on the board index
Post by: .Darkman on February 01, 2007, 09:00:40 AM
Excellent.
I needed this.
Title: Re: Alternating rows background on the board index
Post by: fuddes on June 21, 2007, 08:37:38 PM
Is there a way to do this on the messageindex.php file too? I applied it in the same way but nothing happened.
Title: Re: Alternating rows background on the board index
Post by: codenaught on June 22, 2007, 01:09:39 AM
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.
Title: Re: Alternating rows background on the board index
Post by: fuddes on June 22, 2007, 02:18:52 PM
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.
Title: Re: Alternating rows background on the board index
Post by: xyxis_fahim on October 26, 2007, 08:41:11 PM
I'm not getting this clearly.

can anyone explain it via demo?
sry
Title: Re: Alternating rows background on the board index
Post by: codenaught 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? (http://www.simplemachines.org/community/index.php?topic=24110.0)

fuddes, if you see this, would you still like help with this?
Title: Re: Alternating rows background on the board index
Post by: xyxis_fahim on October 26, 2007, 10:19:25 PM
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? (http://www.simplemachines.org/community/index.php?topic=24110.0)

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

No I meant like what exactly "Alternating rows background " means
Title: Re: Alternating rows background on the board index
Post by: codenaught on October 26, 2007, 11:28:54 PM
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.
Title: Re: Alternating rows background on the board index
Post by: xyxis_fahim on October 27, 2007, 01:35:49 AM
oh thanks... will give it a try
Title: Re: Alternating rows background on the board index
Post by: falguni1 on November 05, 2007, 12:43:22 AM
good work
Title: Re: Alternating rows background on the board index
Post by: Fiery on December 08, 2007, 11:18:58 PM
Were you able to get everything working as you like?
Title: Re: Alternating rows background on the board index
Post by: DAB Empire on September 07, 2009, 10:32:32 AM
Looks like SMF 2.x has different code.  How can I add this to 2.x?
Title: Re: Alternating rows background on the board index
Post by: Arantor on September 07, 2009, 09:05:28 PM
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.
Title: Re: Alternating rows background on the board index
Post by: DAB Empire on September 08, 2009, 05:46:48 AM
It is just the default template.
Title: Re: Alternating rows background on the board index
Post by: Arantor on September 08, 2009, 06:07:12 AM
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">
Title: Re: Alternating rows background on the board index
Post by: DAB Empire on September 09, 2009, 01:35:17 PM
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:
Title: Re: Alternating rows background on the board index
Post by: Arantor on September 09, 2009, 02:15:41 PM
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.
Title: Re: Alternating rows background on the board index
Post by: 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?
Title: Re: Alternating rows background on the board index
Post by: Arantor on March 17, 2010, 02:51:19 PM
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.
Title: Re: Alternating rows background on the board index
Post by: Super_Benno on May 30, 2011, 10:20:06 AM
does it work in the latest release?