Jump to content

[SOLVED] ROFL I need Help so bad with alternating Row Colors.. WOW


Monkuar

Recommended Posts

Ok I use ipb 1.3 I know im a noob for using it but I desperately need your help!!

 

I am trying to alternate row colors on forum row..

 

Ok here's and example of What i want. I use the exact same style on my Forum too:

 

2nvsdxl.gif

 

 

 

 

 

 

NOw This is what my forum looks like [hence i changed color but i still need alternating row colors]

 

2ue1x78.gif

 

 

 

Now i dont know if I should edit my skin files or .php directly files because I need to find the loop or something omg im so confused..

 

IF you have a microphone or msn please tell me it with a pm so we can talk i desperately need this and could you please please help me.. thanks!!

 

 

and this is the <tr class="ce"> i need to alternate..

 

so it goes <tr class="ce bc1"> then <tr class="ce">  then <tr class="ce bc1"> and ya just keep's doing that for each forum row so it's alternating.. omg

 

please help me im french but i am willing to learn

Link to comment
Share on other sites

You need to show us the code that's outputting that table, but the basic implimentation is as follows;

 

<?php
$i = 0;
while($this is a while loop I excpect you have) {
if($i%2){
$the_class = " class=\"dif-color\"";
} else {
$the_class = "";
}
$i++
echo "<td$the_class>content</td>";
}

Link to comment
Share on other sites

OMG Thank u so much for replying finally.. :)

 

Now do u need the skin_boards.php? or boards.php? file i can send both but here is the output of skin_boards.php this is were i need to change the altnerating tr class...

:

 

 

 

 

 

 

 

 

function ForumRow($info, $subinfo="") {
global $ibforums;
$color_one = 'ce bc1';  
$color_two = 'ce';  
   
$array = array('apple','pine','strawberry',  
                     'pear','banana', 'cranberry','kiwifruit');  
   
$i = 1; 

foreach($array as $value)  
{  
/* 
Check if ($i / 2) is an integer and determine which color to show. 
We will divide the number by 2 
*/  
   
$color = (is_int($i / 2)) ? $color_one : $color_two;
$i++; // Increment $i  
}


return <<<EOF
$color
<tr class="ce">
<td>$image_icon</td>
<td align="left"><b><a href="index.php?showforum={$info['id']}" title="{$info['description']}">{$info['name']}</b></a>{$subinfo} {$info['moderator']}</td>

<td nowrap><span class="desc">Topics:</span> {$info['topics']}<br/><span class="desc">Posts:</span> {$info['posts']}</td>
<td align="left" nowrap class="lc"><span class="desc">{$info['last_post']}</span><br/>» {$info['last_topic']}<br>By {$info['last_poster']}</td>
</tr>

<tr> 

  
EOF;
}

 

Those color_one is all my testing and trying to get it to work sorry.

Link to comment
Share on other sites

The quick fix is to change this line;

 

$color = (is_int($i / 2)) ? $color_one : $color_two;

 

to this...

 

$color = ($i % 2) ? $color_one : $color_two;

 

 

I changed it , now i have.:

 

 

 

return <<<EOF
<tr class="$color">
<td>$image_icon</td>
<td align="left"><b><a href="index.php?showforum={$info['id']}" title="{$info['description']}">{$info['name']}</b></a>{$subinfo} {$info['moderator']}</td>

<td nowrap><span class="desc">Topics:</span> {$info['topics']}<br/><span class="desc">Posts:</span> {$info['posts']}</td>
<td align="left" nowrap class="lc"><span class="desc">{$info['last_post']}</span><br/>» {$info['last_topic']}<br>By {$info['last_poster']}</td>
</tr>

<tr> 


EOF;
}

 

and the tr just shows up as one color...

 

i need to find the php code and loop it in there or something.. because <tr class="$color">

and $color should atlernate ce, ce bc1, ce, ce bc1 but it's not wtf.. lol

 

 

Please dont give up on me guys, im willing to give you guys much help as possible but it be nice if u had a microphone so we can talk..

Link to comment
Share on other sites

Ok hang in there please bro..

 

 

Ok here is the "Render forum row":

 

function process_forum($forum_id="", $forum_data="")
  {
   global $std, $ibforums, $DB;


   	if ($forum_data['subwrap'] == 1)
   	{

   		$printed_children = 0;
   		$can_see_root = FALSE;

   		//--------------------------------------
   		// This is a sub cat forum...
   		//--------------------------------------

   		// Do we have any sub forums here?

   		if ( (isset($this->children[ $forum_data['id'] ])) and (count($this->children[ $forum_data['id'] ]) > 0 ) )
   		{

   			// Are we allowed to see the postable forum stuff?

   			if ($forum_data['sub_can_post'] == 1 and $forum_data['redirect_on'] != 1)
   			{
   				if ( $std->check_perms($forum_data['read_perms']) )
				{
					$forum_data['fid'] = $forum_data['id'];
					$newest = $forum_data;
					$can_see_root = TRUE;

					if (isset($forum_data['last_title']) and $forum_data['last_id'] != "")
					{
						if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $forum_data['id']) )
						{

						   $this->news_topic_id = $forum_data['last_id'];
						   $this->news_forum_id = $forum_data['id'];
						   $this->news_title    = $forum_data['last_title'];

						}
					}
				}
				else
				{
					$newest = array();
				}
			}

   			foreach($this->children[ $forum_data['id'] ] as $idx => $data)
			{
   				//--------------------------------------
				// Check permissions...
				//--------------------------------------

				if ( $std->check_perms($data['read_perms']) != TRUE )
				{
					continue;
				}

				// Do the news stuff first

				if (isset($data['last_title']) and $data['last_id'] != "")
				{
					if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) )
					{

					   $this->news_topic_id = $data['last_id'];
					   $this->news_forum_id = $data['id'];
					   $this->news_title    = $data['last_title'];

					}
				}

				if ($data['last_post'] > $newest['last_post'])
				{

					$newest['last_post']        = $data['last_post'];
					$newest['fid']              = $data['id'];
					//$newest['id']               = $data['id'];
					$newest['last_id']          = $data['last_id'];
					$newest['last_title']       = $data['last_title'];
					$newest['password']         = $data['password'];
					$newest['last_poster_id']   = $data['last_poster_id'];
					$newest['last_poster_name'] = $data['last_poster_name'];
					$newest['status']           = $data['status'];
					$newest['desktop']           = $data['desktop'];
				}

				$newest['posts']  += $data['posts'];
				$newest['topics'] += $data['topics'];

				$printed_children++;

			}

			if ( ($printed_children < 1) && ($can_see_root != TRUE) )
			{
				// If we don't have permission to view any forums
				// and we can't post in this root forum
				// then simply return and the row won't be printed
				// 

				return "";

			}
			//-------------------------------
///-------------------------------
// Get The Subforums
//-------------------------------
$querysub = $DB->query("SELECT name, id, read_perms FROM ibf_forums WHERE parent_id = '{$forum_data['id']}' ORDER BY ibf_forums.position");
if($DB->get_num_rows($querysub) > 0) {
$subinfo = "<span class=desc><br>Subforums: ";
while($subin = $DB->fetch_row($querysub)) {
if ( $subin['read_perms'] != '*' ) {
if ( ! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $subin['read_perms'] ) ) {
$subinfo .= "";
}
else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $subin['read_perms'] ) ) {
$subinfo .= "<a href='{$ibforums->base_url}showforum={$subin['id']}'>{$subin['name']}</a>, ";
}
}
else if ( $subin['read_perms'] == '*' ) {
$subinfo .= "<span class=desc><a href='index.php?showforum={$subin['id']}'>{$subin['name']}</a></span> - ";
}

}

$subinfo = substr ($subinfo, 0, -2);
}


			// Fix up the last of the data

			$newest['last_title'] = strip_tags($newest['last_title']);
			$newest['last_title'] = str_replace( "&#33;" , "!" , $newest['last_title'] );
			$newest['last_title'] = str_replace( """, "\"", $newest['last_title'] );

			if (strlen($newest['last_title']) > 30)
			{
				$newest['last_title'] = substr($newest['last_title'],0,27) . "...";
				$newest['last_title'] = preg_replace( '/&(#(\d+;?)?)?(\.\.\.)?$/', '...', $newest['last_title'] );
			}
			if ($newest['password'] != "")
			{
				$newest['last_topic'] = $ibforums->lang['f_protected'];
			}
			else if($newest['last_title'] != "")
			{

				$newest['last_topic'] = "<a href='{$ibforums->base_url}showtopic={$newest['last_id']}&view=getnewpost' title='{$ibforums->lang['tt_gounread']}'>{$newest['last_title']}</a>";
			}
			else
			{
				$newest['last_topic'] = $ibforums->lang['f_none'];
			}
			//NEWMAN // 

			if ( isset($newest['last_poster_name']))
			{
				if ( ($newest['desktop'] == 0) )
				{
					$solid = "";
					if ($newest['desktop'])
					{
						$solid2 = "<img src={$newest['desktop']}>";
					}

					$newest['last_poster'] = $newest['last_poster_id'] ? "<a href='{$ibforums->base_url}showuser={$newest['last_poster_id']}'>{$newest['last_poster_name']}$solid2</a>"
															       : $newest['last_poster_name'];
				}
				else
				{
					$newest['last_poster'] = $newest['last_poster_id'] ? "<a href='{$ibforums->base_url}showuser={$newest['last_poster_id']}'>{$newest['last_poster_name']}</a>"
															       : $newest['last_poster_name'];
				}

			}
			else
			{
				$newest['last_poster'] = $ibforums->lang['f_none'];
			}

			$newest['img_new_post'] = $std->forum_new_posts($newest, $printed_children > 0 ? 1: 0);

			if ( $newest['img_new_post'] == '<{C_ON_CAT}>' )
			{
				$newest['img_new_post'] = $this->html->subforum_img_with_link($newest['img_new_post'], $forum_data['id']);
			}

			$newest['last_post'] = $std->get_date($newest['last_post'], 'LONG');

			$newest['posts']  = $std->do_number_format($newest['posts']);
			$newest['topics'] = $std->do_number_format($newest['topics']);

			foreach($newest as $k => $v)
			{
				if ($k == 'id')
				{
					continue;
				}
				$forum_data[$k] = $v;
			}

   			$forum_data['moderator'] = $this->get_moderators($forum_id);

return $this->html->ForumRow($forum_data, $subinfo);

   		}
   		else
   		{
   			return "";
   		}

   	}
   	else
   	{

		//--------------------------------------
		// Check permissions...
		//--------------------------------------

		if ( $std->check_perms($forum_data['read_perms']) != TRUE )
		{
			return "";
		}

		//--------------------------------------
		// Redirect only forum?
		//--------------------------------------

		if ( $forum_data['redirect_on'] )
		{
			// Simply return with the redirect information

			if ( $forum_data['redirect_loc'] != "" )
			{
				$forum_data['redirect_target'] = " target='".$forum_data['redirect_loc']."' ";
			}

			$forum_data['redirect_hits'] = $std->do_number_format($forum_data['redirect_hits']);

			return $this->html->forum_redirect_row($forum_data);

		}

		//--------------------------------------
		// No - normal forum..
		//--------------------------------------

		$forum_data['img_new_post'] = $std->forum_new_posts($forum_data);

		if ( $forum_data['img_new_post'] == '<{C_ON}>' )
		{
			$forum_data['img_new_post'] = $this->html->forum_img_with_link($forum_data['img_new_post'], $forum_data['id']);
		}

		$forum_data['last_post'] = $std->get_date($forum_data['last_post'], 'LONG');

		$forum_data['last_topic'] = $ibforums->lang['f_none'];

		if (isset($forum_data['last_title']) and $forum_data['last_id'])
		{

			if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $forum_data['id']) )
			{

			   $this->news_topic_id = $forum_data['last_id'];
			   $this->news_forum_id = $forum_data['id'];
			   $this->news_title    = $forum_data['last_title'];

			}

			$forum_data['last_title'] = strip_tags($forum_data['last_title']);
			$forum_data['last_title'] = str_replace( "&#33;" , "!", $forum_data['last_title'] );
			$forum_data['last_title'] = str_replace( """, "\"", $forum_data['last_title'] );

			if (strlen($forum_data['last_title']) > 30)
			{
				$forum_data['last_title'] = substr($forum_data['last_title'],0,27) . "...";
				$forum_data['last_title'] = preg_replace( "/&(#(\d+;?)?)?\.\.\.$/", '...', $forum_data['last_title'] );
			}
			else
			{
				$forum_data['last_title'] = preg_replace( "/&(#(\d+?)?)?$/", '', $forum_data['last_title'] );
			}

			if ($forum_data['password'] != "")
			{
				$forum_data['last_topic'] = $ibforums->lang['f_protected'];
			}
			else
			{

				$forum_data['last_topic']  = "<a href='{$ibforums->base_url}showtopic={$forum_data['last_id']}&view=getnewpost' title='{$ibforums->lang['tt_gounread']}'>{$forum_data['last_title']}</a>";
			}
		}



			if ( isset($forum_data['last_poster_name']))
			{
				if ( ($forum_data['desktop'] == 0) )
				{
					$solid = "";
					if ($forum_data['desktop'])
					{
						$solid = "<img src={$forum_data['desktop']}>";
					}

					$forum_data['last_poster'] = $forum_data['last_poster_id'] ? "<a href='{$ibforums->base_url}showuser={$forum_data['last_poster_id']}'>{$forum_data['last_poster_name']}$solid</a>"
															       : $forum_data['last_poster_name'];
				}
				else
				{
					$forum_data['last_poster'] = $forum_data['last_poster_id'] ? "<a href='{$ibforums->base_url}showuser={$forum_data['last_poster_id']}'>{$forum_data['last_poster_name']}</a>"
															       : $forum_data['last_poster_name'];
				}

			}
			else
			{
				$forum_data['last_poster'] = $ibforums->lang['f_none'];
			}

		//---------------------------------
		// Moderators
		//---------------------------------

		$forum_data['moderator'] = $this->get_moderators($forum_data['id']);

		$forum_data['posts']  = $std->do_number_format($forum_data['posts']);
		$forum_data['topics'] = $std->do_number_format($forum_data['topics']);

		$forum_data['description'] = str_replace( "<br>", "<br />", $forum_data['description'] );

return $this->html->ForumRow($forum_data, $newest, $subinfo);   



		return $this->html->ForumRow($forum_data);

	}

}

 

 

Then u see at the bottom it does:

return $this->html->ForumRow($forum_data);

 

The htmll->Forumrow is the code I gave u above. (2more posts above). Hope u can help me sir..

 

 

 

Link to comment
Share on other sites

Nope only once :)

 

Sir please is it ok if I setup an ftp account for you so u can access my whole forum and script's and see if u can try to fix it sir please?

 

here is something imght help..

 

it get's called 3 times in boards.php tho.:

 

return $this->html->ForumRow($forum_data, $subinfo);

 

 

then

 

 

 

return $this->html->ForumRow($forum_data, $newest, $subinfo); 

 

 

 

return $this->html->ForumRow($forum_data);

 

 

 

Link to comment
Share on other sites

If that is the case, just do this.....

 

<?php
function ForumRow($info, $subinfo="") {
   global $ibforums;
   $color_one = 'ce bc1'; 
   $color_two = 'ce'; 
   static $i = 0;
   $color = ($i % 2) ? $color_one : $color_two;
   $i++;

   return <<<EOF
      $color
      <tr class="ce">
      <td>$image_icon</td>
      <td align="left"><b><a href="index.php?showforum={$info['id']}" title="{$info['description']}">{$info['name']}</b></a>{$subinfo} {$info['moderator']}</td>

      <td nowrap><span class="desc">Topics:</span> {$info['topics']}<br/><span class="desc">Posts:</span> {$info['posts']}</td>
      <td align="left" nowrap class="lc"><span class="desc">{$info['last_post']}</span><br/>» {$info['last_topic']}<br>By {$info['last_poster']}</td>
      </tr>
      
      <tr>
EOF;
}

Link to comment
Share on other sites

ROFLMAO@@@@@@@@@ HOLY SHIT IT WORKED OMG WHAT"S YOUR PAYPAL I GIVE U $$ NOW DOOD ADD ME ON MSN I GIVE U MONEY WAT IS IT HOW MUCH U WANT USD OR WAT?? OMG GOD BLESS U THANK U SO MUCH GODLY U ARE!!

 

 

i did this:

 

<tr class="$color">

 

and it actually WORKS OMG:

 

2v1qauu.gif

 

LOLOL EPIC <3333333333333

Link to comment
Share on other sites

U added the "static" thing witch iuno wth hell it does but it's a godly function for php I love it i sacred this row code u gave me..

 

It took me over 1.3years to figure this out and u just give it to me in like 5minutes.. your a smart man keep this up bro you will go far thank u again,.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.