Hello

September 02, 2010, 05:01:45 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
What sNews Is: - sNews is a simple, basic, customizable CMS tool suitable for developers with beginner-to-advanced PHP skills. It is also useful to have a good working knowledge of how to work with, set up and manage MySQL databases. sNews is not - geared towards the end-user who knows little or nothing about building and developing PHP-MySQL based websites.
News: Try sNews 1.7 DEMO
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [MOD] ODD-EVEN namebox and numbers in Mikas comments mod.  (Read 2021 times)
Patric Ahlqvist
Nobodys perfect, but Im pretty effing close
Administrator
ULTIMATE member
******

Karma: 65
Posts: 4914


“I'm a self-made man and worships my creator.”


WWW
« on: February 05, 2007, 09:17:45 AM »

Title means, hehe... that this "mod" or whatever makes it possible to style the "namebox" and the numbers of post to appear differently depending on if the post is odd or even. Talking about this: http://p-ahlqvist.com/site-snews/redesign-in-progress/#Comment1 . Now, this is my "test" comments made in order to try my idea, might change as the development of the site goes on... (if it ever Wink )

Ok, now I'm not sure this qualify as a MOD, but I post it here and we can move it to more appropriate place if found out to be something else....

Mika's MOD: http://www.ni5ni6.com/snews-mods/comments-area-styling-and-visuals/ Follow this first, so that you have the right "gofromplace".  You do need to get that in order to be able to style it, now won't ya Wink

You see a bit down the mod that you need to change the info line in snews.php... It's the first function after all variables:
Quote
$tags['comments'] = '<div class="comment_div,style,">,<p class="number">,counter,</p>,<p class="top">,name, wrote this on ,date,edit,</p>,<p class="bottom">,comment,</p>,<br style="clear: both;" /></div>';
Instead of all these p tags, I changed a couple of them to divs, the p class="number" became DIV class="number"... the p class="top" became DIV class="top" and finally p class="bottom" became DIV class="bottom"... Now go see to that it looks like this: (the whole function tags() )
Quote
// INFO LINE TAGS (readmore, comments, date)
function tags($tag) {
   $tags = array(); $tags['infoline'] = '<p class="date">,readmore,comments,date,edit,</p>';
   $tags['comments'] = '<div class="comment_div,style,">,<div class="number">,counter,</div>,<div class="top,topbox,">,name,  skrev kommentar  ,date,edit,</div>,<div class="bottom">,comment,</div>,<br style="clear: both;" /></div>';
   return $tags[$tag];
}
Now that is done, we've established what will show, now we need to show it. A bit down in function comment() you'll find this line:
Quote
foreach ($tag as $tag) {
   switch (true) {
...
Directly after this case: (that effects the whole comment_div)
Quote
case ($tag == 'style'): echo $commentNum %2 == 0 ? ' border_even' : ' border_odd'; break;
You add the case which will effect only the top part (the one containing the name, date, and edit links)
Quote
//Odd-even topbox styling
case ($tag == 'topbox'): echo $commentNum %2== 0 ? ' top_even' : ' top_odd'; break;
Those top_even, top_odd are the classes I call for the topbox to style differently depending on odd or even count of post... we'll come to the actual styling later. Now, if you followed Mikas tut you will have the following line as the case for "number":
Quote
case ($tag == 'counter'):
echo '<a name="'.l('comment').$commentNum.'" title="'.l('comment').' '.$commentNum.'">'.$commentNum.'</a> '; break;
Now this need to change if you want the numbers to have the possibility to change according to odd even state, swap the above Mika code for (Thanks Mika for tutoring and "professorship" that lead me to do this Wink ):
Quote
/ /Odd even number styling in comments
case ($tag == 'counter'):
$my_style = $commentNum %2== 0 ? ' num_even' : ' num_odd'; echo '<a name="'.l('comment').$commentNum.'" title="'.l('comment').' '.$commentNum.'" class="'.$my_style.'">'.$commentNum.'</a>'; break;
So, now we're there again... the num_even, num_odd are the classes I call to make the numbers differ depending on if it's odd or even post.

that was the "namebox" and "numbers" the bottom part I don't go change since it's within the comment_div and change with that (border_odd, border_even).

Now we need to do some styling... And in this example I'll just copy Mika's basic CSS style for this:
Quote
.comment_div {background: #f8f8fa; color: #808080; padding: 0; margin: 0; border-top: 1px solid #ccc; font-size: 90%;}
.comment_div p {margin: 0 .5em; padding: 0;}
p.top, p.bottom q {font-style: italic;}
p.top {text-align: right;}
p.bottom q {margin: 1em; padding: .3em; background: #fff; border-left: 3px solid #e0e0e0; display: block;}
p.bottom {margin-top: .5em; color: #000;}
p.bottom:first-letter {margin-left: .5em; text-transform: uppercase;}
p.bottom:first-letter, .number a {font-weight: 900;}
.number a {float: left; margin-top: .2em; padding: .3em 0; font-size: 250%; color: #e0e0e0; border: 1px solid #fff;}
And add the added div's styling, first the top, and the classes that style it depending on odd or even:
Quote
.top{position:relative;float:left;margin:-2em 0 0em -1em;padding:0.5em 1em 0.5em 1em;border:1px solid #ddd;}
.top_odd{background:#EDECDA}
.top_even{background:#E6E6B3}
Second: the bottom, we need to place the bottom div somewhere don't we:
Quote
.bottom{clear:both;float:left;margin:0em 1em 1em 1em;width:90%;}
third, the number (here you need to remove Mika's whole .number a line and swap it for this):
Quote
.number {clear:both;float:right; margin: 0em 0.8em 0 0; padding: .3em 0;width:20px; }
.num_even  {font-size: 200%;color:#E6E6B3;}
.num_odd {font-size:200%;color:#EDECDA;}
.num_even:hover, .num_odd:hover {color:#ddd;}
Now, we're done... One thing though... hehe... this might look like crap as this is the basic tutorial CSS styling with added div's and classes from me, so you might wanna go over the style once more to add your personal touch to it...

So, well...Ok... Cheerio, Ms Sophie Wink
« Last Edit: March 01, 2009, 04:43:11 AM by Joost » Logged

My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs
Zucye
Sr. Member
****

Karma: 5
Posts: 354



WWW
« Reply #1 on: June 13, 2007, 04:33:12 PM »

Quote from: Patric
/ /Odd even number styling in comments
case ($tag == 'counter'):
$my_style = $commentNum %2== 0 ? ' num_even' : ' num_odd'; echo ''.$commentNum.''; break;
Do I this part?  It seems to work the same with or without it.   :/  I am so confused Sad
Logged

We can always learn from our failures, not so much from obvious success - C. Robinson (W. Disney). Smiley
Patric Ahlqvist
Nobodys perfect, but Im pretty effing close
Administrator
ULTIMATE member
******

Karma: 65
Posts: 4914


“I'm a self-made man and worships my creator.”


WWW
« Reply #2 on: June 13, 2007, 09:00:08 PM »

Mhm... hardly remember this at all... In the 1.6 the only thing I add besides the changes to the function infoline () is this snippet inside function comments():
Code:
// New code to number ans style comments
case ($tag == 'style'): echo $commentNum %2 == 0 ? ' border_even' : ' border_odd'; break;
//Odd even topbox styling
case ($tag == 'topbox'): echo $commentNum %2== 0 ? ' top_even' : ' top_odd'; break;
case ($tag == 'counter'):
// Odd even number styling in comments
 $my_style = $commentNum %2== 0 ? ' num_even' : ' num_odd'; echo ''.$commentNum.''; break;
And this piece of code goes between :
Code:
switch (true) {
and the:

Code:
case ($tag == 'date'):
Once again... between these two last snippet you add the bigger one above, and it should be a go... (and function info line should be changed of course).

I can't give you lines as I have not the original snews, so they would be slightly off... There, my darling, is it good now? What that snippet you ask about do or don't is beyond me, hehe, Mika needs to step in to explain that, but it do work this way, that I can tell ya.
Logged

My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs
Pages: [1]
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!