Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: custom style switcher  (Read 5173 times)

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
custom style switcher
« on: April 29, 2007, 02:30:34 PM »

Not sure if this could be classed as a mod, of just a handy little tool, so am posting in here, where it will live or die :)
based on flamewolf's requirements.
http://www.solucija.com/forum/viewtopic.php?pid=29145#p29145

in this form, it is to output the desired style sheet filename to allow alternate styling of
admin pages
logged in but not in admin
page type articles
defaulting to regular style.css if none of the above apply
Quote
function styleChooser(){
// for all page type articles -- get reserved and user defined
$catList = explode(',',l('cat_listSEF'));
$regPageList = array('home','archive','contact','sitemap');
$arraydiff = array_diff($catList,$regPageList);
$categorySEF = get_id('category');
$pageSEF = get_id('article');
   switch (true){
      case ((retrieve('position', 'articles', 'seftitle', $pageSEF)==3) || in_array($categorySEF,$regPageList)== true):$style='pages.css';break;
      case (!isset($_GET['action']) && !in_array($categorySEF,$arraydiff) && $_SESSION[db('website').'Logged_In'] == token()): $style='logged.css';break;
      case ((isset($_GET['action'])||in_array($categorySEF,$arraydiff)) && $_SESSION[db('website').'Logged_In'] == token()): $style='admin.css'  ;break;
      default:$style='style.css';
   }return $style;
}
useage.
place the above in snews.php
in index.php, stylesheet line can become
Quote
Logged
Of all the things I have lost, it is my mind that I miss the most.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
custom style switcher
« Reply #1 on: April 29, 2007, 02:56:47 PM »

it will live for me.
Thanks Phil.  :)
A little question : imagine you'ld like to have differents headers for differents pages (fixed, not random) ? How would you tell sNews to manage this ?

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
custom style switcher
« Reply #2 on: April 29, 2007, 03:01:11 PM »

probably a cross between this and http://www.solucija.com/forum/viewtopic.php?id=3962
Logged
Of all the things I have lost, it is my mind that I miss the most.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
custom style switcher
« Reply #3 on: April 29, 2007, 04:55:21 PM »

:)
Get it !
Thanks Phil

Davor

  • Newbie
  • *
  • Karma: 0
  • Posts: 13
    • Bijeli Anđeli
custom style switcher
« Reply #4 on: May 28, 2007, 05:33:07 PM »

Hello!
I'm using sNews 1.5.31 + MU GAL 1.2 and it does not work well for non Admin users. Is there any possibility for MU GAL 1.2 compatible version anytime soon?

Thanks

EDIT: MU GAL 1.2 compatible version:
Add this code to function styleChooser() function.

Code: [Select]
case (!isset($_GET['action']) && !in_array($categorySEF,$arraydiff) && $_SESSION[db('website').'User_Logged_In'] == tuga()): $style='logged.css';break;
case ((isset($_GET['action'])||in_array($categorySEF,$arraydiff)) && $_SESSION[db('website').'User_Logged_In'] == tuga()): $style='admin.css'  ;break;
EDIT 2:

I've also noticed that if 'home' is in array bellow, multiple pages won't display properly (it will switch to different CSS style for pages > 1).
Code: [Select]
$regPageList = array('home','archive','contact','sitemap');I still haven't found solution to this problem :(
It only appears when admin or other users are logged in.
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: custom style switcher
« Reply #5 on: November 24, 2007, 01:11:44 AM »

what can the stylesheet line become?
Logged