4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 23, 2014, 12:22:26 AM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [Mod] Newsletter inkl. News RSS Feed(Optional)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Current Topic Rating: *****
Author Topic: [Mod] Newsletter inkl. News RSS Feed(Optional)  (Read 5880 times)
Rembrandt
Moderator
4images Guru
*****
Offline Offline

Posts: 4081

Thank You
-Given: 106
-Receive: 856

Vienna


View Profile WWW
« on: April 24, 2011, 06:56:56 PM »

Hi!

The old News(Newsletter) [Mod] here in the forum by the Thread-Opener no longer supported.
This is my Version from a News system.

with this modification you can write news.
the newest message can be displayed on the "home.html", older messages are displayed on its own "news.html"
you can set how many news per page, and how many days remain a news as "new" marked.

new files:
1.) new  SQL Table "News"
2.) admin/news.php
3.) root/news.php
4.) your template/news.html
5.) your template/news_bit.html

modifying files:
6.) admin/index.php
7.) admin/setting.php
8.) includes/constants.php
9.) includes/page_header.php
10.) lang/your lang/admin.php
11.) lang/your lang/main.php

Optional: If the latest message is displayed on the home.html
12.) root/index.php
13.) your template/home.html

Optional News RSS Feed

1.) copy the file "install news.php" (see attachment) on your root and and call it to.

2.) create a new file "news.php" and copy into root/admin:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: news.php                                             *
 *        Copyright: (C) 2002-2011 Jan Sorgalla                           *
 *            Email: jan@4homepages.de                                    * 
 *              Web: http://www.4homepages.de                             * 
 *    Scriptversion: 1.7.10                                               *
 *    Fileversion: 2.0 (for admin) by Rembrandt (www.vienna-pictures.com) *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

define('IN_CP'1);
define('ROOT_PATH''./../');
require(
'admin_global.php');

if (
$action == ""){
  
$action "modifynews";
}

function 
delete_news($news_ids){
  global 
$site_db$lang;
  if (empty(
$news_ids)){
    echo 
$lang['no_search_results'];
    return 
false;
  }
  
$error_log = array();

  
$sql "DELETE FROM ".NEWS_TABLE."
          WHERE news_id IN (
$news_ids)
         "
;
  
$result $site_db->query($sql);

  
$nd $site_db->affected_rows(); 
  echo (
$nd 1)? $lang['news_deleted']:$lang['news_deleted'];

  return 
$error_log;
}

show_admin_header();

if (
$action == "deletenews"){
  
$deletenews = (isset($HTTP_POST_VARS['deletenews'])) ? $HTTP_POST_VARS['deletenews'] : array();
  
$news_ids "";
  if (!empty(
$deletenews))
  {
    foreach (
$deletenews as $val) {
      
$news_ids .= (($news_ids != "") ? ", " "").$val;
    }
  }
  
show_table_header($lang['news_deletion'], 1);
  echo 
"<tr><td class=\"tablerow\">\n";
  echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td>&nbsp;</td><td>\n";
  
$error_log delete_news($news_ids);
  echo 
"</td></tr></table>\n";
  echo 
"</td></tr>\n";
  
show_table_footer();
  echo 
"<br>";
  
show_text_link($lang['back_overview'], "news.php?action=modifynews");
}

if (
$action == "removenews"){
  
$news_ids = array();
  if (isset(
$HTTP_GET_VARS['news_id']) || isset($HTTP_POST_VARS['news_id']))
  {
    
$news_id = (isset($HTTP_GET_VARS['news_id'])) ? intval($HTTP_GET_VARS['news_id']) : intval($HTTP_POST_VARS['news_id']);
    
$news_ids[] = $news_id;
  }
  elseif (isset(
$HTTP_POST_VARS['deletenews']))
  {
    
$news_ids $HTTP_POST_VARS['deletenews'];
  }
  else {
   
$news_ids[] = 0;
  }

  
show_form_header("news.php""deletenews");
  foreach (
$news_ids as $val) {
    
show_hidden_input("deletenews[]"$val);
  }
  
$lang_key = (sizeof($news_ids) > 1) ? 'news' 'news';
  
show_table_header($lang['delete'].": ".sizeof($news_ids).' '.$lang[$lang_key], 2);
  
show_description_row(sprintf($lang['news_deletion_confirmation'], sizeof($news_ids)));
  
show_form_footer($lang['yes'], ""2$lang['no']);
}

if (
$action == "updatenews"){
  
$error = array();
  
$news_id = (isset($HTTP_POST_VARS['news_id'])) ? intval($HTTP_POST_VARS['news_id']) : intval($HTTP_GET_VARS['news_id']);

  
$news_title un_htmlspecialchars(trim($HTTP_POST_VARS['news_title']));
  
$news_text un_htmlspecialchars(trim($HTTP_POST_VARS['news_text']));
  
$news_date trim($HTTP_POST_VARS['news_date']);

  if (
$news_title == "") {
    
$error['news_title'] = 1;
  }
  if (
$news_text == "") {
    
$error['news_text'] = 1;
  }
  if (
$news_date == "") {
    
$error['news_date'] = 1;
  }

  if (empty(
$error)) {

    
$news_date = ($news_date != "") ? "UNIX_TIMESTAMP('$news_date')" time();

    
$sql "UPDATE ".NEWS_TABLE."
            SET news_title = '
$news_title', news_text = '$news_text', news_date=$news_date
            WHERE news_id = 
$news_id";
    
$result $site_db->query($sql);

    
$msg = ($result) ? $lang['news_modified'] : $lang['news_modified_nok'];
  }
  else {
    
$msg .= sprintf("<span class=\"marktext\">%s</span>"$lang['lostfield_error']);
  }
  
$action "editnews";
}

if (
$action == "editnews"){
  
$news_id = (isset($HTTP_POST_VARS['news_id'])) ? intval($HTTP_POST_VARS['news_id']) : intval($HTTP_GET_VARS['news_id']);

  
$sql "SELECT user_id, user_name, news_title, news_text, news_date FROM ".NEWS_TABLE." WHERE news_id = ".$news_id;

  
$result $site_db->query($sql);
  
$news_row $site_db->fetch_array($result);

  
show_form_header("news.php""updatenews""form"1);
  
show_hidden_input("news_id"$news_id);

  
show_table_header($lang['edit'].': '.sprintf($lang['edit_news_title'], $news_id$news_row['user_name']), 2);

  
show_input_row($lang['news_title'], "news_title"$news_row['news_title'], $textinput_size);
  
show_textarea_row($lang['news_content'], "news_text"$news_row['news_text'], 100,10);
  
show_input_row($lang['news_date'], "news_date"date("Y-m-d H:i"$news_row['news_date']), $textinput_size);

  
show_form_footer($lang['save_changes'], $lang['reset'], 2);
  
    if (
$msg != "") {
    
printf("<b>%s</b>\n"$msg."&nbsp;");
  
show_text_link($lang['back_overview'], "news.php?action=modifynews");
  
show_text_link($lang['news_overview'], "".$site_sess->url(ROOT_PATH."news.php" )."",1);
  }
}

if (
$action == "savenews"){
  
$error = array();

 
$news_title un_htmlspecialchars(trim($HTTP_POST_VARS['news_title']));
 
$news_text un_htmlspecialchars(trim($HTTP_POST_VARS['news_text']));

  if (
$news_title == "") {
    
$error['news_title'] = 1;
  }
  if (
$news_text == "") {
    
$error['news_text'] = 1;
  }

  if (empty(
$error)) {
  
    
$current_time time();
    
$sql "INSERT INTO ".NEWS_TABLE."
            (user_id, user_name, news_title, news_text, news_date)
            VALUES
            ("
.$user_info['user_id'].", '".$user_info['user_name']."', '$news_title', '$news_text', $current_time)
           "
;
    
$result $site_db->query($sql);
    if (empty(
$news_id)) {
      
$news_id $site_db->get_insert_id();
    }

    
show_table_header($lang['news_add'], 1);
    echo 
"<tr><td class=\"tablerow\">\n";
    echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td>&nbsp;</td><td>\n";
    echo 
$lang['news_add_ok']."<br >";
    echo 
"</td></tr></table>\n";
    echo 
"</td></tr>\n";
    
show_table_footer();
    echo 
"<br>";
    
show_text_link($lang['back_overview'], "news.php?action=modifynews");
    
show_text_link($lang['news_add'], "news.php?action=addnews");
    
show_text_link($lang['news_overview'], "".$site_sess->url(ROOT_PATH."news.php" )."",1);
  }
  else {
    
$msg .= sprintf("<span class=\"marktext\">%s</span>"$lang['lostfield_error']);
    
$action "addnews";
  }
}


if (
$action == "addnews"){
  if (
$msg != "") {
    
printf("<b>%s</b>\n"$msg);
  }
  
show_form_header("news.php""savenews""form"1);
  
show_table_header($lang['news_add'], 2);
  
show_input_row($lang['news_title'], "news_title"""$textinput_size);
  
show_textarea_row($lang['news_content'], "news_text"""$textarea_size);
  
show_form_footer($lang['add'], $lang['reset'], 2);
  
show_text_link($lang['back_overview'], "news.php?action=modifynews");
  
show_text_link($lang['news_overview'], "".$site_sess->url(ROOT_PATH."news.php" )."",1);
}


if (
$action == "modifynews"){
  
show_form_header("news.php""findnews""form");
  
show_table_header($lang['modify_news'], 2);
  
show_input_row($lang['news_author'], "user_name"""$textinput_size);
  
show_input_row($lang['news_title'], "news_title"""$textinput_size);
  
show_input_row($lang['news_content'], "news_text"""$textinput_size);
  
show_table_separator($lang['sort_options'], 2);
  
?>
  <tr class="<?php echo get_row_bg(); ?>"><td><p><b><?php echo $lang['order_by']; ?></b></p></td><td><p>
  <select name="orderby">
  <option value="user_name"><?php echo $lang['news_author']; ?></option>
  <option value="news_title"><?php echo $lang['news_title']; ?></option>
  <option value="news_date" selected><?php echo $lang['news_date']; ?></option>
  </select>
  <select name="direction">
  <option value="ASC"><?php echo $lang['asc']; ?></option>
  <option selected value="DESC"><?php echo $lang['desc']; ?></option>
  </select>
  </p></td></tr>
  <?php
  show_input_row
($lang['results_per_page'], "limitnumber"50);
  
show_form_footer($lang['search'], $lang['reset'], 2);
}

if (
$action == "findnews"){
 
$site_sess->set_session_var('back_url'$self_url);
  
$condition "1=1";

  
$user_name trim($HTTP_POST_VARS['user_name']);
  if (
$user_name != "") {
    
$condition .= " AND INSTR(LCASE(n.user_name),'".strtolower($user_name)."')>0";
  }
  
  
$news_title trim($HTTP_POST_VARS['news_title']);
  if (
$news_title != "") {
    
$condition .= " AND INSTR(LCASE(n.news_title),'".strtolower($news_title)."')>0";
  }

  
$news_text trim($HTTP_POST_VARS['news_text']);
  if (
$news_text != "") {
    
$condition .= " AND INSTR(LCASE(n.news_text),'".strtolower($news_text)."')>0";
  }

  
$orderby trim($HTTP_POST_VARS['orderby']);
  if (
$orderby == "") {
    
$orderby "n.news_date";
  }
  
$limitstart = (isset($HTTP_POST_VARS['limitstart'])) ? trim($HTTP_POST_VARS['limitstart']) : "";
  if (
$limitstart == "") {
    
$limitstart 0;
  }
  else {
    
$limitstart--;
  }
  
$limitnumber trim($HTTP_POST_VARS['limitnumber']);
  if (
$limitnumber == "") {
    
$limitnumber 5000;
  }

  if (isset(
$HTTP_GET_VARS['direction']) || isset($HTTP_POST_VARS['direction'])) {
    
$direction = (isset($HTTP_GET_VARS['direction'])) ? trim($HTTP_GET_VARS['direction']) : trim($HTTP_POST_VARS['direction']);
  }
  else {
    
$direction "DESC";
  }

  
$sql "SELECT COUNT(*) AS news 
           FROM "
.NEWS_TABLE." n
           LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = n.user_id)
           WHERE 
$condition";
  
$countnews $site_db->query_firstrow($sql);
  
$limitfinish $limitstart $limitnumber;

  
$start 0;
  if (
$countnews['news'] > 0) {
    
$start $limitstart 1;
  }

  echo 
$lang['found']." <b>".$countnews['news']."</b>. ".$lang['showing']." <b>$start</b>-";
 
  if (
$limitfinish $countnews['news'] == 0) {
    echo 
"<b>".$limitfinish."</b>.";
  }
  else {
    echo 
"<b>".$countnews['news']."</b>.";
  }
  
show_form_header("news.php""removenews""form");
  echo 
"<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" align=\"center\"><tr><td class=\"tableborder\">\n<table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\">\n";
  if (
$countnews['news'] > 0){
  
    
$sql "SELECT n.news_id, n.user_id, n.user_name, n.news_title, n.news_text, n.news_date".get_user_table_field(", u.""user_name")."
            FROM "
.NEWS_TABLE." n
            LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = n.user_id)
            WHERE 
$condition
            ORDER BY 
$orderby $direction
            LIMIT 
$limitstart$limitnumber";

    
$result $site_db->query($sql);
    echo 
"<tr class=\"tableseparator\">\n";
    echo 
"<td class=\"tableseparator\"><input name=\"allbox\" type=\"checkbox\" onClick=\"CheckAll();\" ></td>\n";
    echo 
"<td class=\"tableseparator\">".$lang['news_author']."</td>\n
    <td class=\"tableseparator\">"
.$lang['news_title']."</td>\n
    <td class=\"tableseparator\">"
.$lang['news_content']."</td>\n
    <td class=\"tableseparator\">"
.$lang['news_date']."</td>\n
    <td class=\"tableseparator\">"
.$lang['options']."</td>\n</tr>\n";

    while (
$news_row $site_db->fetch_array($result)) {
      echo 
"<tr class=\"".get_row_bg()."\">";
      echo 
"<td><input type=\"checkbox\" name=\"deletenews[]\" value=\"".$news_row['news_id']."\" ></td>";

      
$show_user_name htmlspecialchars($news_row['user_name']);
      if (
$news_row[$user_table_fields['user_id']] != GUEST && empty($url_show_profile)) {
        
$show_user_name "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$news_row['user_id'])."\" target=\"_blank\">$show_user_name</a>";
      }
      echo 
"<td><b>".$show_user_name."</b></td>\n";
      echo 
"<td>".htmlspecialchars($news_row['news_title'])."</td>\n";
      echo 
"<td>".htmlspecialchars($news_row['news_text'])."</td>\n";
      echo 
"<td>".format_date($config['date_format']." ".$config['time_format'], $news_row['news_date'])."</td>\n";
      echo 
"<td><p>";

      
show_text_link($lang['edit'],"news.php?action=editnews&news_id=".$news_row['news_id']);
      
show_text_link($lang['delete'],"news.php?action=removenews&news_id=".$news_row['news_id']);
      echo 
"&nbsp;&nbsp;";
      echo 
"</p></td>\n";
      echo 
"</tr>\n";
    }
    
show_form_footer($lang['delete'],"");
  }
  else {
    
show_description_row($lang['no_search_results'], 6);
    
show_form_footer("""");
  }

  echo 
"<div align=\"left\">";
  echo 
"<form action=\"".$site_sess->url("news.php")."\" name=\"form2\" method=\"post\">\n";

    
show_hidden_input("action""findnews");
    
show_hidden_input("user_level"$user_level);
    
show_hidden_input("user_name"$user_name1);
    
show_hidden_input("user_email"$user_email1);
    
show_hidden_input("dateafter"$dateafter);
    
show_hidden_input("datebefore"$datebefore);
    
show_hidden_input("lastactionafter"$lastactionafter);
    
show_hidden_input("lastactionbefore"$lastactionbefore);
    
show_hidden_input("orderby"$orderby1);
    
show_hidden_input("direction"$direction1);
    
show_hidden_input("limitstart"$limitstart $limitnumber 1);
    
show_hidden_input("limitnumber"$limitnumber);

  if (
$limitstart 1) {
    echo 
"<input type=\"button\" value=\"   ".$lang['back']."  \" onclick=\"limitstart.value=limitstart.value-limitnumber.value*2;submit();\" class=\"button\">\n";
  }
    
  if (
$limitnumber != 5000 && $limitfinish $countnews['news']) {
    echo 
"<input type=\"submit\" value=\"   ".$lang['search_next_page']."   \" class=\"button\">\n";
  } 
   echo
"<br><br>";
  
show_text_link($lang['back_overview'], "news.php?action=modifynews");
  echo 
"</form>";
  echo 
"</div>";
}
show_admin_footer();
?>

3.) create a new file "news.php" and copy into root:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: news.php                                             *
 *        Copyright: (C) 2002-2011 Jan Sorgalla                           *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.10                                               *
 *    Fileversion: 2.0(for Member) by Rembrandt (www.vienna-pictures.com) *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
$main_template 'news';
define('GET_CACHES'1);
define('ROOT_PATH''./');
define('MAIN_SCRIPT'__FILE__);
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
include(
ROOT_PATH.'includes/page_header.php');

  
$sql "SELECT COUNT(news_id) AS news 
          FROM "
.NEWS_TABLE."
          "
;
  
$result $site_db->query_firstrow($sql);
  
$num_news $result['news'];
  
$site_db->free_result();

  
$num_rows_all = (isset($num_news)) ? $num_news 0;

  
$link_arg $site_sess->url(ROOT_PATH."news.php");
  include_once(
ROOT_PATH.'includes/paging.php');
  
$getpaging = new Paging($page$config['news_page'], $num_rows_all);

  
$offset $getpaging->get_offset();

  
$site_template->register_vars(array(
    
"paging" => $getpaging->get_paging(),
    
"paging_stats" => $getpaging->get_paging_stats()
  ));
  
  
$sql "SELECT news_id, news_title, news_text, user_name, news_date 
          FROM "
.NEWS_TABLE.
          ORDER BY news_date DESC
          LIMIT 
$offset, ".$config['news_page']."
         "
;

  
$result $site_db->query($sql);
  
$num_rows $site_db->get_numrows($result);
  
  
$news_row = array();
  while (
$row $site_db->fetch_array($result)){
    
$news_row[] = $row;
  }

  if (!
$num_rows){
    if (
$user_info['user_level'] == ADMIN){
      
$admin_links_add "<a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=addnews"))."\" >".$lang['add']."</a>&nbsp;";
    }
    
$news "";
    
$msg $lang['no_news'];
    
$site_template->register_vars(array(
       
"lang_news_main" => $lang['news_main'],
       
"admin_links_add" => ($admin_links_add) ? $admin_links_add:""
    
));
  }
  else {
    for (
$i 0$i $num_rows$i++){
      
//$comment_user_name = htmlspecialchars($news_row[$i]['user_name']);

      
$admin_links "";
      if (
$user_info['user_level'] == ADMIN){
        
$admin_links_add "<a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=addnews"))."\" >".$lang['add']."</a>&nbsp;";
        
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=editnews&amp;news_id=".$news_row[$i]['news_id']))."\">".$lang['edit']."</a>&nbsp;";
        
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=removenews&amp;news_id=".$news_row[$i]['news_id']))."\">".$lang['delete']."</a>";
      }
      
      
$news_text str_replace("/>"">",$news_row[$i]['news_text']);
       
      
$new_is_new = ($news_row[$i]['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
      
$site_template->register_vars(array(
        
"lang_news_main" => $lang['news_main'],
        
"news_title" => "<b>".$news_row[$i]['news_title']."</b>".(($new_is_new)?" <sup class=\"new\">".$lang['new']."</sup>":""). "<span class=\"smalltext\">".$lang['news_from'].""$news_row[$i]['user_name'].""$lang['news_on'].""format_date($config['date_format']." ".$config['time_format'], $news_row[$i]['news_date'])."</span>",
        
"news_text" =>  format_text($news_text$config['news_html'], 0$config['news_bbcode'], $config['news_bbcodeimg']),
        
"admin_links" => $admin_links,
        
"admin_links_add" => ($admin_links_add) ? $admin_links_add:"",
        
"news_id" => $news_row[$i]['news_id']
      ));
      
$news .= $site_template->parse_template("news_bit");
    } 
// end for
  
}
   
  
$site_template->register_vars("content"$news);
  unset(
$news);
  
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".$lang['news_main']."",
  
"rss_url"   => $script_url."/rss.php?action=news"
 
));
  
//-----------------------------------------------------
//---Clickstream---------------------------------------
//-----------------------------------------------------
$txt_clickstream $lang['news_main'];
$clickstream "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
  if (
$getpaging->page 1){
    
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."news.php")."\">".$lang['news_main']."</a>".$config['category_separator'].$lang['page']." ".$getpaging->page."</span>";
  }
  else{
    
$clickstream .= $txt_clickstream."</span>";
  }
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream
));

$site_template->print_template($site_template->parse_template($main_template));
include(
ROOT_PATH.'includes/page_footer.php');
?>

4.) copy your template/error.html, rename it to "news.html" and store it again in your template folder.
search in the new file "news.html":
1
2
3
<b class="title">{lang_error}</b>
<hr size="1" />
<p>{error_msg}</p>
and replace:
1
2
3
4
5
6
<b class="title">{lang_news_main}</b>
<div style="margin:0px 0px;text-align:right">{admin_links_add}</div>                  
<hr size="1">
{content}
{paging}
<p>&nbsp;</p>

5.) create a new file "news_bit.html" and copy in your template folder:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td class="bordercolor">
      <table width="100%" border="0" cellpadding="3" cellspacing="0">
        <tr>
        <a name="news_{news_id}">
          <td class="head1" width="50%">{news_title}</td>
          <td class="head1" width="50%" align="right">{if admin_links}{admin_links}{endif admin_links}</td>
        </tr>
         <tr>
          <td style="padding:5px" colspan="2" class="catbgcolor">{news_text}</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br>

6.) search in admin/index.php:
1
show_nav_option($lang['nav_comments_edit'], "comments.php?action=modifycomments");
insert below:
1
2
3
4
5
//############################### Start News #########################################          
          
show_nav_header($lang['news_main']);
          
show_nav_option($lang['news_add'], "news.php?action=addnews");
          
show_nav_option($lang['modify_news'], "news.php?action=modifynews");
//############################### End News ########################################### 

7.) search in admin/setting.php:
1
show_setting_row("highlight_admin""radio");
insert below:
1
2
3
4
5
6
7
8
//######################### Start News ##########################
  
show_table_separator($setting_group[8], 2"setting_group_8");
	
show_setting_row("news_page");
	
show_setting_row("news_isnew");
	
show_setting_row("news_html""radio");
	
show_setting_row("news_bbcode""radio");
	
show_setting_row("news_bbcodeimg""radio");
//######################### End News ############################

8.) search in includes/constants.php:
1
define('WORDMATCH_TABLE'$table_prefix.'wordmatch');
insert below:
1
2
3
//############## Start News ####################
define('NEWS_TABLE'$table_prefix.'news');
//############## End News ######################

9.) search in includes/page_header.php:
1
"url_new_images" => $site_sess->url(ROOT_PATH."search.php?search_new_images=1"),
insert above:
1
2
3
//############################# Start News ###################################### 
  
"url_news" => $site_sess->url(ROOT_PATH."news.php"),
//############################# End News ########################################
9.1) search:
1
  "lang_site_stats" => $lang['site_stats'],
insert above:
1
"lang_news_main" => $lang['news_main'],


10.) search in lang/your lang/admin.php:
(deutsch)
1
2
  "2" => "Durch den Admin"
);
insert below:
1
2
3
4
5
6
7
8
9
//###########################+# Start News ##############################################
/*-- Setting-Group 8 --*/
$setting_group[8] = "News";
$setting['news_page'] = "Wieviele 'News' pro Seite";
$setting['news_isnew'] = "Wie viele Tage soll eine 'News' als neu gekennzeichnet werden";
$setting['news_html'] = "HTML in 'News' erlauben";
$setting['news_bbcode'] = "BB-Code in 'News' erlauben";
$setting['news_bbcodeimg'] = "Image Tags in 'News' erlauben";
//############################## End News ###############################################
(english)
1
2
  "2" => "by Admin"
);
insert below:
1
2
3
4
5
6
7
8
9
//###########################+# Start News ##############################################
/*-- Setting-Group 8 --*/
$setting_group[8] = "News";
$setting['news_page'] = "How many 'News' per Page";
$setting['news_isnew'] = "Number of days each 'News' is marked as new";
$setting['news_html'] = "Allow HTML in 'News'";
$setting['news_bbcode'] = "Allow BB-Code in 'News'";
$setting['news_bbcodeimg'] = "Allow Image Tags in 'News'"
//############################## End News ###############################################

11.) search in lang/your lang/main.php:
insert above:
(deutsch)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//############################### Start News ######################################
$lang['news_main'] = 'News';
$lang['no_news'] = "Derzeit keine neue Nachrichten.";
$lang['news_deleted'] = ' News gelöscht';
$lang['news_deletion'] = 'News löschen';
$lang['news_overview'] = 'Zurück zur News Übersicht';
$lang['news'] = 'News';
$lang['news_modified'] = 'News erfolgreich Bearbeitet.';
$lang['news_modified_nok'] = 'Fehler beim Bearbeiten der News.';
$lang['news_deletion_confirmation'] = 'Wollen Sie wirklich diese %s News löschen?';
$lang['edit_news_title'] = 'News Eintrag #%d pupliziert von %s';
$lang['news_title'] = 'Titel';
$lang['news_content'] = 'Text';
$lang['news_date'] = 'Datum';
$lang['modify_news'] = 'News Bearbeiten';
$lang['news_author'] = 'Autor';
$lang['news_add'] = 'News hinzufügen';
$lang['news_add_ok'] = 'News Erfolgreich hinzugefügt.';
$lang['news_from'] = " -- von ";
$lang['news_on'] = " am ";
$lang['news_archive'] = '[Archiv]';
$lang['page'] = 'Seite';
$lang['add'] = "[Hinzufügen]";
//################################ End News ######################################
(english)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//############################### Start News ######################################
$lang['news_main'] = 'News';
$lang['no_news'] = "Currently no new News.";
$lang['news_deleted'] = ' News deleted';
$lang['news_deletion'] = 'Delete News';
$lang['news_overview'] = 'Back to News';
$lang['news'] = 'News';
$lang['news_modified'] = 'News successfully edited.';
$lang['news_modified_nok'] = 'Error processing News.';
$lang['news_deletion_confirmation'] = 'Do you really want to delete these %s News?';
$lang['edit_news_title'] = 'News #%d added by %s';
$lang['news_title'] = 'Title';
$lang['news_content'] = 'Text';
$lang['news_date'] = 'Date';
$lang['modify_news'] = 'Edit News';
$lang['news_author'] = 'Author';
$lang['news_add'] = 'Add News';
$lang['news_add_ok'] = 'News successfully added.';
$lang['news_from'] = " -- from ";
$lang['news_on'] = " at ";
$lang['news_archive'] = '[Archiv]';
$lang['page'] = 'Page';
$lang['add'] = "[Add News]";
//################################ End News ######################################


Optional: If the latest message is displayed on the home.html

12.) search in root/index.php:
1
2
//-----------------------------------------------------
//--- Show Categories ---------------------------------
insert above:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//############################################## Start News ###########################################################
  
$sql "SELECT news_id, news_title, news_text, user_name, news_date 
          FROM "
.NEWS_TABLE.
          ORDER BY news_date DESC
          LIMIT 1
        "
;

  
$result $site_db->query($sql);
  
$news_row $site_db->fetch_array($result);

  if (!
$news_row){
    
$news_text $lang['no_news']."&nbsp<a href=\"".$site_sess->url(ROOT_PATH."news.php")."\" >".$lang['news_archive']."</a>"
    
$site_template->register_vars(array(
      
"lang_news_main" => $lang['news_main'],
      
"news_text" =>  format_text($news_text$config['news_html'], 0$config['news_bbcode'], $config['news_bbcodeimg']),
    ));
  }
  else {
    
$admin_links "";
    if (
$user_info['user_level'] == ADMIN){
      
$admin_links_add "<a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=addnews"))."\" >".$lang['add']."</a>&nbsp;";
      
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=editnews&amp;news_id=".$news_row['news_id']))."\">".$lang['edit']."</a>&nbsp;";
      
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=removenews&amp;news_id=".$news_row['news_id']))."\">".$lang['delete']."</a>";
    }
    
    
$news_text str_replace("/>"">",$news_row['news_text']);

    
$new_is_new = ($news_row['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
    
$site_template->register_vars(array(
      
"lang_news_main" => $lang['news_main']." -- ",
      
"news_title" => "<b>".$news_row['news_title']."</b>".(($new_is_new)?" <sup class=\"new\">".$lang['new']."</sup>":"")."</span>",
      
"news_date" => "<b><span class=\"smalltext\">"format_date($config['date_format']." ".$config['time_format'], $news_row['news_date'])."</span>",
      
"news_text" =>  format_text($news_text$config['news_html'], 0$config['news_bbcode'], $config['news_bbcodeimg'])."&nbsp;&nbsp;<br><br><a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."news.php")."\" > ".$lang['news_archive']."</a>",
      
"admin_links" => $admin_links,
      
"admin_links_add" => ($admin_links_add) ? $admin_links_add:"",
      
"news_id" => $news_row['news_id']
    ));
  }
//#################################################### End News ################################################### 

13.) search in your template/home.html:
1
{if categories}
insert above:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
                {if news}
                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr>
                            <td class="head1" valign="top">{lang_news_main}{news_title}</td>
                            <td class="head1"  align="right">{news_date}</td>
                          </tr>
                          <tr>
                            <td style="padding:5px"class="catbgcolor" valign="top" colspan="2">{news_text}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <br />
                  {endif news}<br>

mfg Andi

* install_news.php (6.06 KB - downloaded 69 times.)
« Last Edit: May 16, 2011, 05:49:11 AM by Rembrandt » Logged

Meine 4Images Modifikationen  Now over 100 Modification Online!    Meine 4images Demo Seite


Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
mmarschner
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 3
-Receive: 1


View Profile WWW
« Reply #1 on: May 15, 2011, 05:43:17 PM »

Hallo Andi,

schöne MOD, jedoch mit einem Fehler im admin\main.php. Dort hast Du

$setting['news_page'] = "How many "News" per Page";
....

eingegeben. Es darf jedoch nur 'News' lauten, also keine doppelten Hochkommata, sondern nur einfache.

Danke dafür, dass Du Dir die viele Mühe machst, und solche MODs entwickelst.

Michael
Logged

Wozu brauchen wir Kernkraftwerke - fahrt doch lieber alle Rad.

MotOly - die Domäne für Motorradfahrer, die mit Olympus fotografieren.
Marion
Newbie
*
Offline Offline

Posts: 20

Thank You
-Given: 16
-Receive: 1


View Profile WWW
« Reply #2 on: May 15, 2011, 11:04:57 PM »

Vielen Dank für die Mod, kann ich sehr gut gebrauchen und ist klasse gemacht !

Hatte auch nur 2 Probleme beim Einbau (4images 1.7.9)
Zum einen funktionierte im ACP jeweils der Link "zurück zur Newsübersicht" nicht; gab immer eine 404 Errorseite, obwohl die news.php im Root-Ordner lag und die news.html im Template-Ordner.
Habe ich gelöst bekommen, indem ich in der news.php, die in den Admin-Ordner kommt an 3 Stellen
1
.$site_sess->url(ROOT_PATH."news" )
hinter  news jeweils noch .php gesetzt habe.

Und ebenfalls im ACP funktionierte bei mir auf der Einstellungsseite der Anker oben nicht. Habe ich gelöst bekommen, indem ich in der settings.php hier
1
 show_table_separator($setting_group[8], 2"#setting_group_8");
das # entfernt habe.
Logged
MrAndrew
Sr. Member
****
Offline Offline

Posts: 301

Thank You
-Given: 9
-Receive: 12


View Profile WWW
« Reply #3 on: January 21, 2012, 10:04:58 AM »

Step 12 not work "LIMIT" param... I`ve done some changes with code:

In step 12 search in root/index.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//############################################## Start News ###########################################################
  
$sql "SELECT news_id, news_title, news_text, user_name, news_date 
          FROM "
.NEWS_TABLE.
          ORDER BY news_date DESC
          LIMIT 1
        "
;

  
$result $site_db->query($sql);
  
$news_row $site_db->fetch_array($result);

  if (!
$news_row){
    
$news_text $lang['no_news']."&nbsp<a href=\"".$site_sess->url(ROOT_PATH."news.php")."\" >".$lang['news_archive']."</a>"
    
$site_template->register_vars(array(
      
"lang_news_main" => $lang['news_main'],
      
"news_text" =>  format_text($news_text$config['news_html'], 0$config['news_bbcode'], $config['news_bbcodeimg']),
    ));
  }
  else {
    
$admin_links "";
    if (
$user_info['user_level'] == ADMIN){
      
$admin_links_add "<a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=addnews"))."\" >".$lang['add']."</a>&nbsp;";
      
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=editnews&amp;news_id=".$news_row['news_id']))."\">".$lang['edit']."</a>&nbsp;";
      
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=removenews&amp;news_id=".$news_row['news_id']))."\">".$lang['delete']."</a>";
    }
    
    
$news_text str_replace("/>"">",$news_row['news_text']);

    
$new_is_new = ($news_row['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
    
$site_template->register_vars(array(
      
"lang_news_main" => $lang['news_main']." -- ",
      
"news_title" => "<b>".$news_row['news_title']."</b>".(($new_is_new)?" <sup class=\"new\">".$lang['new']."</sup>":"")."</span>",
      
"news_date" => "<b><span class=\"smalltext\">"format_date($config['date_format']." ".$config['time_format'], $news_row['news_date'])."</span>",
      
"news_text" =>  format_text($news_text$config['news_html'], 0$config['news_bbcode'], $config['news_bbcodeimg'])."&nbsp;&nbsp;<br><br><a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."news.php")."\" > ".$lang['news_archive']."</a>",
      
"admin_links" => $admin_links,
      
"admin_links_add" => ($admin_links_add) ? $admin_links_add:"",
      
"news_id" => $news_row['news_id']
    ));
  }
//#################################################### End News ################################################### 

Then replace this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//############################################## Start News ###########################################################
  
$news_text "";
  
$num_news 4;
  
  
$sql "SELECT news_id, news_title, news_text, user_name, news_date 
          FROM "
.NEWS_TABLE.
          ORDER BY news_date DESC
          LIMIT 
$num_news";
          
    
$result $site_db->query($sql);
  
$news_row $site_db->get_numrows($result);
  

  while (
$news_row $site_db->fetch_array($result)){

    
$news_date = (isset($news_row['news_date'])) ? format_date($config['date_format'], $news_row['news_date']) : REPLACE_EMPTY;
    
$new_is_new = ($news_row['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
    
$news_text .= "<table border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">"
    
$news_text .= "<td align=\"left\">";
    
$news_text .= "<b><span class=\"smalltext\">".$news_date."</span> | <b> ".$news_row['news_title']."</b>".(($new_is_new)?" <sup class=\"smalltext\"><font color=\"#f6f16e\"> (".$lang['new'].")</font></sup>":"")."</span>";
    
$news_text .= "</td>"
    
$news_text .= "</tr>";
    
$news_text .= "</table>";
     
    }
    
$site_template->register_vars("news_text"$news_text);
    unset(
$news_text);

//#################################################### End News ################################################### 

Change "$num_news = 4" in the code by number how many news do you need!
Logged

ASAD
Jr. Member
**
Offline Offline

Posts: 59

Thank You
-Given: 8
-Receive: 4


View Profile WWW
« Reply #4 on: November 14, 2012, 07:37:36 PM »

Danke Rembrandt für tolle mod.
Hab frage, ist es möglich die "News" kurze auf der "home.html" zeigen (mit "weiter lesen")?
Z.B. 200 simbol von 500-1000
Ich denke, Sie verstehen, was ich meine.  Smile
Logged

Sumale.my
Addicted member
******
Offline Offline

Posts: 1787

Thank You
-Given: 161
-Receive: 75

Neverdie


View Profile
« Reply #5 on: January 26, 2013, 03:10:35 PM »

Ich habe das ganze mit der Erweiterung von Mr.Andrew erweitert: http://www.4homepages.de/forum/index.php?topic=29522.msg160647#msg160647
Ich hätte aber gerne auch eine Weiterlesefunktion für die News.

Ich lasse mir immer die letzten 3 News ausgeben. Für jede einzelne wäre es super wenn man diese Weiterlesen könnte. [weiter lesen...]
Unter der News.php sieht man ja alle
Logged
Sumale.my
Addicted member
******
Offline Offline

Posts: 1787

Thank You
-Given: 161
-Receive: 75

Neverdie


View Profile
« Reply #6 on: February 09, 2013, 01:33:15 PM »

Ebenfalls wären Kommentare echt super
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.16 seconds with 21 queries.