Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [MOD] Setting separate style on admin section (sNews 1.4)  (Read 4601 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
[MOD] Setting separate style on admin section (sNews 1.4)
« on: August 27, 2006, 12:15:05 am »

Following up on Howard's suggestion in this thread: http://www.solucija.com/forum/viewtopic.php?id=1453, the following slight mod allows you to set a special style on the admin section, a style that is only visible when you're logged in. For a visual example of how the mod works, visit http://www.frdk.com/test/, click on the safety vault icon at bottom left of any page and log into the admin section with username test, password liverpool

*****************
BACKUP YOUR FILES!

(I'll only say it once)
*****************

1. Make a copy of the normal stylesheet, change whatever style bits you want in order for the admin section to look special, and save this stylesheet as -for example- admin.css. Just make sure that the name and location matches that which you put into snews.php (next step)

2. In snews.php, find // TITLE and add this on a new line before "javascript_headers();":
Quote
if (isset($_SESSION['Logged_In'])) {
echo "\n";
} else {
echo "\n";
}
3. In index.php, find and remove this line:
Quote
or -if you're using another template than the default sNews 1.4 template- the corresponding line that calls the 'normal' stylesheet. Because we piggyback the title function in snews.php, we don't need to add anything to the index.php file, that is done automagically.

And, well, that's all. ;D
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #1 on: August 27, 2006, 02:19:26 am »

Absolutely simple and smooth! Can't say anything more. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

flamewolf

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
    • http://www.badwolf.com.au/blog
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #2 on: September 26, 2006, 02:24:12 am »

Is there anyway to do this in snews 1.5? The coding has been changed slightly in the new 1.5.
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #3 on: September 26, 2006, 06:28:19 am »

1.5 solution is very similar, actually ;)

1.4 (shorter version)
Quote
$style = isset($_SESSION['Logged_In']) ? 'admin' : 'style';
echo '';
1.5 (shorter version)
Quote
$style = isset($_SESSION[db('website').'Logged_In']) ? 'admin' : 'style';
echo '';
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

flamewolf

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
    • http://www.badwolf.com.au/blog
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #4 on: September 26, 2006, 08:19:04 am »

I am assuming that this once again goes in the "title" area of the source code.  Thanks, Mika

Quote from: mika
1.5 solution is very similar, actually ;)

1.4 (shorter version)
Quote
$style = isset($_SESSION['Logged_In']) ? 'admin' : 'style';
echo '';
1.5 (shorter version)
Quote
$style = isset($_SESSION[db('website').'Logged_In']) ? 'admin' : 'style';
echo '';
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #5 on: September 26, 2006, 09:58:01 am »

exactly, just follow agent's footsteps and replace his 2. //TITLE snippet with mine ;)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

flamewolf

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
    • http://www.badwolf.com.au/blog
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #6 on: September 28, 2006, 06:20:50 am »

Quote from: mika
exactly, just follow agent's footsteps and replace his 2. //TITLE snippet with mine ;)
Could someone provide a snews.php code dump with this mod included for me?  I have tried doing it myself, but I end up with either of 2 problems ,

the stylesheet (default) gets comepletely disabled even after I moved it to the folder "images" (as in the php code) or I end up with a stream of MYSQL errors.  Am I doing something wrong?
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #7 on: September 28, 2006, 07:40:59 am »

sorry wolf, I forgot about stylesheet link inside index.php - in order to apply this mod, it must be removed or commented

this is modded sNews v1.5.26 title() function:
Quote
// TITLE
/*
important:
- remove or comment stylesheet link in index.php
- create a new admin.css file inside folder /images/
*/

function title() {
   echo '';
   $categorySEF = get_id('category'); $articleSEF = get_id('article');
   $categoryName = retrieve('description', 'categories', 'seftitle', $categorySEF);
   $articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
   if (!empty($articleTitle)) {$title = $articleTitle.' - ';}
   if (!empty($categoryName)) {$title .= $categoryName.' - ';}
   $title .= s('website_title');
   echo ''.$title.'';
   echo '';
   if (!empty($articleSEF)) {
      $query = "SELECT * FROM ".db(prefix)."articles WHERE seftitle = '$articleSEF'";
      $result = mysql_query($query);
      while ($r = mysql_fetch_array($result)) {$dmeta = $r['description_meta']; $kmeta = $r['keywords_meta'];}
   }
   echo '';
   echo '';
   if (isset($_SESSION[db('website').'Logged_In'])) {js(); $style = 'admin';}
   else {$style = 'style';}
   echo '';

}
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #8 on: September 28, 2006, 07:47:47 am »

Took the words right out of my mouth, mika ;D
With this mod in place, the hardcoded stylesheet reference in index.php needs to be removed or commented out. Otherwise it won't work as expected.

I'll do a variation of this mod once 1.5 is stable, to include a styleswitcher (for accessibility purposes among other things).
Logged

flamewolf

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
    • http://www.badwolf.com.au/blog
[MOD] Setting separate style on admin section (sNews 1.4)
« Reply #9 on: September 28, 2006, 08:51:07 am »

thanks guys.......
Logged