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.

Pages: [1] 2

Author Topic: Separate admin area, is it possible?  (Read 12036 times)

aditan22

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Separate admin area, is it possible?
« on: May 24, 2007, 05:18:53 AM »

Yeah, I'm thinking to separate the admin area from the main and user's screen, it's because I put some new articles, extra etc on main page and I don't want them to appear when I'm accessing the admin screen. I have tried to check the Logged_In status but it makes another issue, if I prevent some parts not being displayed when I have been logged in, I have to back and forth login and logout to see the main page. Err... I hope I can show you my test site but currently it's being developed in my local server.

So is it possible? how difficult?
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Separate admin area, is it possible?
« Reply #1 on: May 24, 2007, 07:23:04 AM »

Basically, sNews is not designed in this way.  What you are asking is going to require a lot of recoding, if that is it is at all possible.

You're on the right path with the Logged_In status, using else if statements, however, as you noted, you will need to log in and out to see the changes.

Someone else here with a little more knowledge of the script and PHP may be able to steer you in the right direction.  Hang tight!
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Joost

  • Guest
Separate admin area, is it possible?
« Reply #2 on: May 24, 2007, 08:20:05 AM »

My approach would be hiding the extra content, using css.
For that, a (php)style switch is needed.
Look for (line 327 in sNews 1.6 or line 303 in 1.5):
Code: [Select]
if ($_SESSION[db('website').'Logged_In'] == token()) {js(); }replace this line with:
Code: [Select]
if ($_SESSION[db('website').'Logged_In'] == token()) {js();
echo '<link rel="stylesheet" type="text/css" href="hide.css" media="screen" />';
} else {

echo '<link rel="stylesheet" type="text/css" href="style.css" media="screen" />';
}
Now remove this line from index.php (same as 'else'):
Code: [Select]
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />You will have to make two stylesheets:
style.css for the the visitors, who are not logged in.
hide.css used for the administrator when logged in.  In hide.css, you style the site to your own convenience, hide whatever you want or make elements smaller. for example:
Code: [Select]
div.box {display:none}In this approach you still have to log  out to see the result. Maybe someone can make the switch to work for
?action=admin etc. only.
« Last Edit: September 10, 2008, 04:22:52 PM by Joost »
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Separate admin area, is it possible?
« Reply #3 on: May 24, 2007, 08:30:04 AM »

IMHO it requires just a few code lines and IMHO few code lines might allow to keep two separate, transparent and clean layouts (one for publishing and one for administration).

So one of possible solutions (without any login/logout frenzy) might be as follows:

(1) create plain function in snews.php to detect what action is being done:
Code: [Select]
function publishing() {
   $result = ($_SESSION[db('website').'Logged_In'] == token()) ? false : true;
   return $result;
}
(2) in index.php <body> ... </body> part is repeated twice:
Code: [Select]
<?php if ( publishing() ) { ?>
<body> ... publishing layout ... </body>
<?php  } else { ?>
<body> ... administration layout ... </body>
<?php  ?>
(3) refine initially created function publishing() until it detects not only logged in/out, but display of content in administration part as well:
Code: [Select]
function publishing() {
   $result = ($_SESSION[db('website').'Logged_In'] == token()) ? false : true;
   if (!$result) {
      // First administration content test here
      // $result = false;
   }
   if (!$result) {
      // Second administration content test here
      // $result = false;
   }
   return $result;
}
Anyway this is solution that I'm using to some extent - so its doable and actually its simple one ;)
« Last Edit: September 10, 2008, 04:23:08 PM by Joost »
Logged

aditan22

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Separate admin area, is it possible?
« Reply #4 on: May 24, 2007, 09:06:05 AM »

Thanks for all your suggestions guys... you absolutely have a nice trick there. :)

Well it seems there's no single variable to be checked to determine if we're accessing admin form or not. Hmm... maybe I need to add that variable myself  :rolleyes:  but still I need to determine what conditions that state we're in admin mode. I got some so far:
- category = 'administration'
- category like 'extra%'
- action like 'admin%'

what else? am I in the right direction?
Logged

Joost

  • Guest
Separate admin area, is it possible?
« Reply #5 on: May 24, 2007, 09:11:52 AM »

Astonishing. :rolleyes:  Part (2) is very confusing. Both bodies outside the php tags, but they are not displayed at the same time? I have got a lot to learn.:/ For you it is simple.
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Separate admin area, is it possible?
« Reply #6 on: May 24, 2007, 09:13:07 AM »

Additionally this mod might help with ideas how to determine context.
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Separate admin area, is it possible?
« Reply #7 on: May 24, 2007, 09:19:29 AM »

@Joost : Those body tags are located in ifs true and false branches; so, only one of them get chances to be shown at any given time. As for that easy part I'm in IT for some 20+ years already and coding is more like hobby now ;)
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
Separate admin area, is it possible?
« Reply #8 on: May 24, 2007, 09:35:28 AM »

Mhm... why not use something like this... http://www.solucija.com/forum/viewtopic.php?pid=29983#p29983
Logged
"It's only dead fish that goes with the flow... "
Updated

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Separate admin area, is it possible?
« Reply #9 on: May 24, 2007, 09:46:49 AM »

That's good one when public and administration areas are similar with exception for some elements. However, sometimes it's required to have public layout formatted in a way that's really makes it unsuitable for administration. In such cases it might be preferable to have two clean and completely different layout. And that leaves a lot of room for some creative design frenzy in public area still keeping administration area editor friendly  :D
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Separate admin area, is it possible?
« Reply #10 on: May 24, 2007, 09:53:09 AM »

And are there any particular reasons why doing this with v.1.5 when 1.6 is out?
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
Separate admin area, is it possible?
« Reply #11 on: May 24, 2007, 10:11:48 AM »

Possibly, if having modded the hell out the existing 1.5 and not feeling up for a change ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Separate admin area, is it possible?
« Reply #12 on: May 24, 2007, 01:16:36 PM »

Quote from: codetwist
That's good one when public and administration areas are similar with exception for some elements. However, sometimes it's required to have public layout formatted in a way that's really makes it unsuitable for administration. In such cases it might be preferable to have two clean and completely different layout. And that leaves a lot of room for some creative design frenzy in public area still keeping administration area editor friendly  :D
Totally agree...

Variant on Codetwists above, would be to have both layouts as seperate files, and index.php with the regular topline in snews, with codies script using includes instead of full layouts....

just my thoughts...
Logged
Of all the things I have lost, it is my mind that I miss the most.

aditan22

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Separate admin area, is it possible?
« Reply #13 on: May 24, 2007, 02:40:03 PM »

Quote from: codetwist
Additionally this mod might help with ideas how to determine context.
Hmm this one is interesting mod, I will dig it further to see if it can solve my problem.

Quote from: codetwist
And are there any particular reasons why doing this with v.1.5 when 1.6 is out?
yeah, I was with 1.5 when 1.6 hadn't released and I have also modified some functions. Why? does 1.6 have separate  user and admin page?
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Separate admin area, is it possible?
« Reply #14 on: May 25, 2007, 02:04:11 AM »

No 1.6 doesn't have that at all.
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future
Pages: [1] 2