Advertisement:

Author Topic: Alternating rows background on the board index  (Read 34756 times)

Offline anunlike

  • Sr. Member
  • ****
  • Posts: 746
  • Gender: Male
Alternating rows background on the board index
« on: October 05, 2005, 02:33:01 PM »
for the board index - BoardIndex.template.php

change:
Code: [Select]
// 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:
Code: [Select]
// 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}
« Last Edit: October 05, 2005, 03:07:03 PM by Compuart »

Offline .Darkman

  • Full Member
  • ***
  • Posts: 508
  • Gender: Male
  • Templora.com
    • Templora
Re: Alternating rows background on the board index
« Reply #1 on: February 01, 2007, 09:00:40 AM »
Excellent.
I needed this.
Clever Tutorials - One place for all of them . . .
SMF Theme Works



fuddes

  • Guest
Re: Alternating rows background on the board index
« Reply #2 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.

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Alternating rows background on the board index
« Reply #3 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.
Dev Consultant
Former SMF Doc Coordinator

fuddes

  • Guest
Re: Alternating rows background on the board index
« Reply #4 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.

Offline xyxis_fahim

  • Jr. Member
  • **
  • Posts: 213
Re: Alternating rows background on the board index
« Reply #5 on: October 26, 2007, 08:41:11 PM »
I'm not getting this clearly.

can anyone explain it via demo?
sry

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Alternating rows background on the board index
« Reply #6 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?
Dev Consultant
Former SMF Doc Coordinator

Offline xyxis_fahim

  • Jr. Member
  • **
  • Posts: 213
Re: Alternating rows background on the board index
« Reply #7 on: October 26, 2007, 10:19: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

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Alternating rows background on the board index
« Reply #8 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.
Dev Consultant
Former SMF Doc Coordinator

Offline xyxis_fahim

  • Jr. Member
  • **
  • Posts: 213
Re: Alternating rows background on the board index
« Reply #9 on: October 27, 2007, 01:35:49 AM »
oh thanks... will give it a try

Offline falguni1

  • Full Member
  • ***
  • Posts: 652
  • Gender: Female
  • http://beautymakeupdivas.com/
Re: Alternating rows background on the board index
« Reply #10 on: November 05, 2007, 12:43:22 AM »
good work

Offline Fiery

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,209
  • Gender: Male
  • Community Builder
Re: Alternating rows background on the board index
« Reply #11 on: December 08, 2007, 11:18:58 PM »
Were you able to get everything working as you like?

Offline DAB Empire

  • Jr. Member
  • **
  • Posts: 240
  • Gender: Male
  • EliteRides.com
    • Night Clubs
Re: Alternating rows background on the board index
« Reply #12 on: September 07, 2009, 10:32:32 AM »
Looks like SMF 2.x has different code.  How can I add this to 2.x?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,051
    • Arantor on GitHub
Re: Alternating rows background on the board index
« Reply #13 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline DAB Empire

  • Jr. Member
  • **
  • Posts: 240
  • Gender: Male
  • EliteRides.com
    • Night Clubs
Re: Alternating rows background on the board index
« Reply #14 on: September 08, 2009, 05:46:48 AM »
It is just the default template.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,051
    • Arantor on GitHub
Re: Alternating rows background on the board index
« Reply #15 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

Code: [Select]
// 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">
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline DAB Empire

  • Jr. Member
  • **
  • Posts: 240
  • Gender: Male
  • EliteRides.com
    • Night Clubs
Re: Alternating rows background on the board index
« Reply #16 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

Code: [Select]
      // 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:

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,051
    • Arantor on GitHub
Re: Alternating rows background on the board index
« Reply #17 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline snowalker

  • Newbie
  • *
  • Posts: 4
Re: Alternating rows background on the board index
« Reply #18 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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,051
    • Arantor on GitHub
Re: Alternating rows background on the board index
« Reply #19 on: March 17, 2010, 02:51:19 PM »
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.