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: Separating the Center Function.  (Read 6972 times)

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« on: December 05, 2006, 04:09:22 pm »

Hello, first i really like the way this cms is working.
Ok: Now the whole left content on the cms is working in one function ( center();).
I would like to create new functions for all the other content that i have and can manually update myself through the system. Does anyone know how to do this? Thanks in advance
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Separating the Center Function.
« Reply #1 on: December 05, 2006, 04:13:26 pm »

Center() is used to display articles/comments and pages (public part of the site), and to manage contents (admin part of the site). Would you like to add another behaviour? What did you had in mind exactly?
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #2 on: December 05, 2006, 04:15:07 pm »

Hello thanks for quick respond,
What i want is i have one left big box. There i want to put a welcome message, The latest news. I would like to create it so i can edit those two smaller boxes in my admin panel and i think one function cant handle that?
Thanks
Logged

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
    • http://www.snewscms.com
Separating the Center Function.
« Reply #3 on: December 05, 2006, 04:20:41 pm »

Just put the Extra function and you can control it's dependancy.

Code: [Select]
index.php:

Logged

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #4 on: December 05, 2006, 04:22:40 pm »

Yes but then it displays all the info after eachother. like this: http://www.painlessdesigns.net/cms/
Thats what happens(note i didn't edit the css of the extra function).
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Separating the Center Function.
« Reply #5 on: December 05, 2006, 04:25:34 pm »

Luka's right (that's the main purpose of extra() function).

Another option would be to do this: there's a large switch at the top of function center() that you can edit to fit your preferences
- create new functions
- add them to switch
- edit your index.php

or you could create your functions outside center() if you want to perform new tasks differently, and place it in your index.php like this
Quote




your-welcome-message



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

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #6 on: December 05, 2006, 04:28:24 pm »

Ok yeah thats probably what i the way i want it. Thank you. I will try it out :)
Logged

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #7 on: December 05, 2006, 05:03:56 pm »

Sorry could you show me an example how option one would look like? My PHP is not really well at the moment. :(
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Separating the Center Function.
« Reply #8 on: December 05, 2006, 05:24:51 pm »

Note - this is just a basic example:

snews.php
Quote
function welcome() {
# in your snews database create a new table [welcome] with columns [id], [message]
# query db (displaying only the first message)

$query = "SELECT * FROM ".db('prefix')."welcome ORDER by id DESC LIMIT 0,1";
$result = mysql_query($query);
    while ($r = mysql_fetch_array($result)) {
        # display message formatted as paragraph
        echo '

'.$r['message'].'

';
    }
}
index.php
Quote


If you want to know more about sNews modding and/or PHP functions please take a look at php.net manual... and you might find my article useful as well ;)

EDIT: option one?

find switch ($action) { part of the code in function center and add this line as follows:
Quote
function center() {
...
switch ($action) {
...
break;
default:
welcome();
if ($processed == false) {
}
and your welcome function will always be on top of all centered contents when in "public" mode
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #9 on: December 05, 2006, 06:00:28 pm »

Aah i see. Thank you very much :)
Logged

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #10 on: December 10, 2006, 10:18:04 am »

Hello the function works now, now i'm trying to add it to the admin page so i can edit it. Could you tell me where in the script i have to add code to let it work in the admin panel?
Thanks
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Separating the Center Function.
« Reply #11 on: December 10, 2006, 10:47:46 am »

You need to build a new editing form especially for welcome section or modify existing one (look for form_articles() function inside snews.php). After that, you need to attach its processing variables into processing() function or use some other way to acomplish that..
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #12 on: December 10, 2006, 10:52:05 am »

hmm ok will try that. Thank you
Logged

Ph0eNiX

  • Newbie
  • *
  • Karma: 0
  • Posts: 14
Separating the Center Function.
« Reply #13 on: December 16, 2006, 04:47:45 pm »

Hello could you please explain me what this code does:
Code: [Select]
if (!empty($id)) {
echo '<p><label for="pos">'.l('position').':</label>
<select name="position" id="pos">';
echo '<option value="1"'.$frm_position1.'>'.l('center').'</option>';
echo '<option value="2"'.$frm_position2.'>'.l('side').'</option>';
echo '<option value="3"'.$frm_position3.'>'.l('display_page').'</option>';
echo '</select></p>';
}
else {html_input('hidden', 'position', 'position', $pos, '', '', '', '', '', '', '', '', '', '', '');}
if ($contents != 'extra_new' && $edit_option != '2') {
html_input('text', 'description_meta', 'dm', $frm_meta_desc, l('description_meta'), 'smalltxtarea', '', '', '', '', '2', '100', '', '', '');
html_input('text', 'keywords_meta', 'km', $frm_meta_key, l('keywords_meta'), 'smalltxtarea', '', '', '', '', '2', '100', '', '', '');
}
html_input('checkbox', 'display_title', 'dt', 'YES', l('display_title'), '', '', '', '', $frm_display_title, '', '', '', '', '');
if ($contents != 'extra_new' && $edit_option != '2') {
html_input('checkbox', 'display_info', 'di', 'YES', l('display_info'), '', '', '', '', $frm_display_info, '', '', '', '', '');
html_input('checkbox', 'commentable', 'ca', 'YES', l('enable_commenting'), '', '', '', '', $frm_commentable, '', '', '', '', '');
if (!empty($id)) {
echo '<p><input name="freeze" type="checkbox" id="fc"';
if ($r['commentable'] == 'FREEZ') {echo ' checked="checked">';}
else if ($r['commentable'] == 'YES') {echo '>';}
echo ' <label for="fc"> '.l('freeze_comments').'</label></p>';
}
}
Thanks in advance.
« Last Edit: December 30, 2009, 07:36:24 pm by Keyrocks »
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
Separating the Center Function.
« Reply #14 on: December 16, 2006, 10:58:40 pm »

This is an excerpt from form_articles() function. You should examine another function - html_input() - first, or use commented snews.php version from my signature below ;)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version
Pages: [1] 2