Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] - In Progress - Administration Message  (Read 1835 times)

ens

  • Sr. Member
  • ****
  • Karma: 12
  • Posts: 279
    • http://www.meatysite.info
[MOD] - In Progress - Administration Message
« on: June 23, 2007, 09:21:20 pm »

Hey everyone, I decided to start working on a mod I wanted to implement in my own site. This is the first thing I have ever done with PHP so bear with me...

What it does is, in a separate fieldset at the top in the admin section, it would display a message from another administrator, or the main administrator. So far, I have accomplished this, but the message is hardcoded as a language variable in snews.php. This is what I've done:

Add to the administration language variables:
Quote
$l['adminmessage'] = 'Welcome to the panel';
$l['adminnotice'] = 'Testing, 123 hehe';
Then find
Quote
foreach ($_POST as $key) {unset($_POST[$key]);}
in the //ADMINISTRATION FORM function. Directly below it, add
Quote
echo html_input('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '','' .l('adminmessage'));
echo '

'.l('adminnotice');
echo '

';
Now, this works, but the message must be made in $l['adminnotice'], and therefore is not dynamic or easily changeable.

What I want to do is create a little textarea in the "Site settings" area which writes the message to the database, then have the $l['adminnotice'] access that field in the database and print it to the screen... or echo or whatever. I though of using what the "Extra Contents" function uses, but I didn't know exactly what to use.. like I said, this is my first php.

Any help would be greatly appreciated.
Logged

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
[MOD] - In Progress - Administration Message
« Reply #1 on: June 24, 2007, 12:17:39 am »

Hello ens

Maybe you can add new fields in settings:

Add language variables
   $l['adminmessage'] = 'Panel Message';
   $l['adminnotice'] = 'Message to show';

execute in sql
Code: [Select]
INSERT INTO SETTINGS (name) VALUES ('adminmessage');
INSERT INTO SETTINGS (name) VALUES ('adminnotice');
Anywhere in settings function, add
Code: [Select]
echo html_input('text', 'adminmessage', 'admsg', s('adminmessage'), l('adminmessage'), '', '', '', '', '', '', '', '', '', '');
echo html_input('text', 'adminnotice', 'admnot', s('adminnotice'), l('adminnotice'), '', '', '', '', '', '', '', '', '', '');
find
Code: [Select]
case 'save_settings':
if (isset($_POST['save'])) {
$website_title = $_POST['website_title'];
just add, before $ufield = array('website_title' =>
Code: [Select]
$adminmessage=$_POST['adminmessage'];
$adminnotice=$_POST['adminnotice'];
inside $ufield = array('website_title' =>
example after ,'word_filter_enable' => $word_filter_enable

add
Code: [Select]
, 'adminmessage' => $adminmessage, 'adminnotice' => $adminnoticewhere you want
echo html_input('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '','' .l('adminnotice'));
echo '

'.s(adminmessage);

Logged
Need a Job on Europe. Linkdin - Facebook / Group

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
[MOD] - In Progress - Administration Message
« Reply #2 on: June 24, 2007, 02:57:51 am »

Sorry a litle bug

Where you want to use (example inside administration)

      if (s('adminmessage')!=''){
         echo html_input('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '','' .s('adminnotice'));
         echo '

'.s('adminmessage').'

';
         echo '';}


switch variables to this
   $l['adminnotice'] = 'Panel Message';
   $l['adminmessage'] = 'Message to show';


It's working

Just need to sleep, bye
Logged
Need a Job on Europe. Linkdin - Facebook / Group