Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Need help - How to make 2 different styles for articles and everything else?  (Read 6307 times)

Kan

  • Newbie
  • *
  • Karma: 0
  • Posts: 22

It concerns multiple layout problem. There are many ways to make multiple layouts described here at the forum. All of them either don't work by me or are too hard to implement, including the proposal to change snews.php completely to the new one.
Actually what I need exactly is simple: I need the default styled text and headlines align (align - left) for everything - home, categories, etc, nothing changed. But for opened articles I need this text and headlines align - to be centered - not depending from categories etc, but everywhere. That's it! It's easy and little and shy wish.
But please! I'm going crazy not finding the way to do it. Help!
Logged

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen

hey kan  :D

try this:
Code: [Select]
<style type="text/css">
<?php
if ( 
get_id('article') != '') {
echo 'h2 { text-align:center; margin:4px auto; }';
echo 'p { text-align:center; margin:4px auto; }';
}
?>

 </style>

# in file index.php
Past the code within the <head>  </head> tags,

you can change the styles to fit your needs,
and yo can change css file aswell.

Code: [Select]

<?php
if ( 
get_id('article') != '') {
           echo 
'<link rel="stylesheet" type="text/css" href="style.css" />';
}
?>



hope it help
« Last Edit: April 23, 2008, 01:04:39 PM by mosh »
Logged

Kan

  • Newbie
  • *
  • Karma: 0
  • Posts: 22

mosh!
Didn't you know? You saved my life!!
That's what I've searched for last 4 days!
I know nothing in programming, and it's because of it. The task was simple but not for me. So now! With this really SIMPLE solution I can have completely different styles for articles and all other content. Thank you thank you thank you.
And  even more. For the first time in my life I've really programmed something : )
I mean this piece of code for calling style.css was not full without some thing that I've added by myself.
And it works. See:
Code: [Select]
<?php
if ( 
get_id('article') != '') {
           echo 
'<link rel="stylesheet" type="text/css" href="stylearticle.css" />';
}
else {echo 
'<link rel="stylesheet" type="text/css" href="style.css" />';
}
?>

So if I want to see articles - it calls out stylearticle.css, or else it calls out style.css

Besides that I have found that I can put instead the word 'article' the word 'category' in there, and it will give me the different style for all categories and articles inherited (very pity, that articles are changing here too).

Well, maybe exists an equally simple solution for different styling of all "home", "categories" and "articles" pages? In order to have as a result the possibility to have, let's say , four different styles for 'articles', 'categories', 'pages', 'home' separately?  It supposed to be, I think, the solution that is as simple as this one above. Not requiring too much coding, like all those "Multiple template MODs". If so, it would be very good to see these variants.
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab

Mosh, can be like in title() function here ? Only the logic, of course (and maybe using elseif?).

« Last Edit: April 23, 2008, 03:04:00 AM by funlw65 »
Logged

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen

 :D you welcome kan, im glad it help.
congratz for first script, i remmber this feelling not to long ago  ;)

# for the category without the articles change the if statment:
Code: [Select]
<?php
if (
get_id('category') != '' && get_id('article') == ''){
echo 'YOUR CODE HERE';
}
?>



more e.g: i have this code to Just add and change the background image for:
contact, archive, sitemap.

note: <div class="boxs"></div> could be any,
the php code was planted inside the style rule.

Code: [Select]
  <style type="text/css">

  .boxs { padding: 10px 5%;
    float: right;
    width: 89.5%;
<?php
$gcat get_id('category');
$pa'background:url(images/';
$pb') no-repeat top left;';
switch($gcat) {
case 'contact'; echo $pa.'page-border22.png'.$pb; break;
case 'sitemap'; echo $pa.'page-border23.png'.$pb; break;
case 'archive'; echo $pa.'page-border24.png'.$pb; break;
}
?>

    }

  </style>


@ fun
yes, it is good solution as well, on most times i prefer use of small bits of code, hehe same reason i love sNews.
the template mods are awesome mods as well to deal with styles.

awesome day to all
 8)
« Last Edit: April 23, 2008, 01:05:03 PM by mosh »
Logged

Kan

  • Newbie
  • *
  • Karma: 0
  • Posts: 22

..and thanks again...
Logged