• [MOD]Another Simple News Publishing Mod 5 0 5 1
Currently:  

Author Topic: [MOD]Another Simple News Publishing Mod  (Read 347668 times)

0 Members and 1 Guest are viewing this topic.

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
[MOD]Another Simple News Publishing Mod
« on: July 27, 2005, 11:22:41 PM »
The Oracle found some errors which required modifications to the MOD. I updated it at 13:50 swisstime 28.07.2005 - thanks TheOracle!
## MOD Title: Another Simple News Publishing Mod
## MOD Author: janfy < janfy@cagades.com > http://www.cagades.com/
## MOD Description: Adds news to your 4images gallery
##
## MOD Version: 1.3.0

Reference:
http://www.4homepages.de/forum/index.php?topic=6787.msg29663#msg29663

##############################################################
## Before Adding This MOD To Your Gallery, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]---------------------------------
#
Code: [Select]
includes/constants.php
#
#-----[ FIND ]---------------------------------
#
Code: [Select]
define('LIGHTBOXES_TABLE', $table_prefix.'lightboxes');
#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: [Select]
define('NEWS_TABLE', $table_prefix.'news');
#
#-----[ OPEN ]---------------------------------
#
index.php

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
unset($categories);
#
#-----[ AFTER, ADD ]------------------------------------------
#

Code: [Select]
//-----------------------------------------------------
// ----- Show news ------------------------------------
//-----------------------------------------------------

if (!isset($config['news_home_display']) || $config['news_home_display'] == 1)
$sql = "SELECT news_title, news_text, user_name, news_date FROM ".NEWS_TABLE." ORDER BY news_date DESC LIMIT 0, ".((isset($config['news_nb']))?$config['news_nb']:5);
else if ($config['news_home_display'] == 2)
$sql = "SELECT news_title, news_text, user_name, news_date FROM ".NEWS_TABLE." WHERE news_date > ".(time() - ((isset($config['news_nb_days']))?$config['news_nb_days']:15)*86400)." ORDER BY news_date DESC";

$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $news = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $news .= $lang['no_news'];
  $news .= "</td></tr></table>";
}
else  {
  $news = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";

  while ($image_row = $site_db->fetch_array($result))
  {
    $news .= "<tr class=\"imagerow1\">\n";
    $news .= "<td width=\"100%\" valign=\"top\">\n";
    $new_is_new = ($image_row['news_date'] > time() - ((isset($config['news_cutoff']))?$config['news_cutoff']:3)*86400);
$news .= "<b>".$image_row['news_title']."</b>".(($new_is_new)?" <sup class=\"new\">".$lang['new']."</sup>":"").sprintf($lang['news_posted_by'], $image_row['user_name'], format_date($config['date_format']." ".$config['time_format'], $image_row['news_date']));
    $news .= "\n</td>\n";
    $news .= "</tr>\n";

    $news .= "<tr class=\"imagerow2\">\n";
    $news .= "<td width=\"100%\" valign=\"top\">\n<br/>";
$news .= format_text($image_row['news_text'], ((isset($config['news_html']))?$config['news_html']:0), 0, ((isset($config['news_bbcode']))?$config['news_bbcode']:1), ((isset($config['news_bbcodeimg']))?$config['news_bbcodeimg']:1));
$news .= "<br/><br/>\n</td>\n";
    $news .= "</tr>\n";

  } // end while

  $news .= "</table>\n";
} // end else

$site_template->register_vars(array(
"news" => $news,
"news_archives" => "<a href=\"".$site_sess->url(ROOT_PATH."news.php"\" class=\"link\">".$lang['news_archive']."</a>",
"news_main" => $lang['news_main']
));
unset($news);

#
#-----[ OPEN ]---------------------------------
#
admin/index.php

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
show_nav_option($lang['nav_comments_edit'], "comments.php?action=modifycomments");
#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: [Select]
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");


#
#-----[ OPEN ]---------------------------------
#
lang/english/main.php

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
$lang['delete'] = "[Delete]";
#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: [Select]
$lang['news_main'] = 'News';
$lang['no_news'] = 'No news';
$lang['news_deleted'] = ' news deleted';
$lang['newss_deleted'] = ' news deleted';
$lang['news_deletion'] = 'News deletion';
$lang['newss'] = 'news';
$lang['news'] = 'news';
$lang['news_modified'] = 'News modified successfully.';
$lang['news_modified_nok'] = 'Error during news modification.';
$lang['news_deletion_confirmation'] = 'Do you really want to delete the %s selected news.';
$lang['edit_news_title'] = 'News #%d posted by %s';
$lang['news_title'] = 'Title';
$lang['news_content'] = 'Content';
$lang['news_date'] = 'Date';
$lang['modify_news'] = 'Edit news';
$lang['news_author'] = 'Author';
$lang['news_add'] = 'Add a news';
$lang['news_add_ok'] = 'News added successfully.';
$lang['news_posted_by'] = ' -- Posted by <b>%s</b> on <i>%s</i>';
$lang['news_archive'] = 'Archives';
$lang['page'] = 'Page';
#
#-----[ OPEN ]---------------------------------
#
lang/french/main.php

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
$lang['delete'] = "[Supprimer]";
#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: [Select]
$lang['news_main'] = 'Nouvelles';
$lang['no_news'] = 'Pas de nouvelle';
$lang['news_deleted'] = ' nouvelle supprimée';
$lang['newss_deleted'] = ' nouvelles supprimées';
$lang['news_deletion'] = 'Suppression de news';
$lang['newss'] = 'nouvelles';
$lang['news'] = 'nouvelle';
$lang['news_modified'] = 'Nouvelle modifiée avec succčs';
$lang['news_modified_nok'] = 'Erreur lors de la modification de la nouvelle.';
$lang['news_deletion_confirmation'] = 'Etes vous sur de vouloir supprimer la(les) %s nouvelle(s) sélectionnée(s)';
$lang['edit_news_title'] = 'Nouvelle #%d postée par %s';
$lang['news_title'] = 'Titre';
$lang['news_content'] = 'Contenu';
$lang['news_date'] = 'Date';
$lang['modify_news'] = 'Editer les nouvelles';
$lang['news_author'] = 'Auteur';
$lang['news_add'] = 'Ajouter une nouvelle';
$lang['news_add_ok'] = 'Nouvelle ajoutée avec succés.';
$lang['news_posted_by'] = ' -- Posté par <b>%s</b> le <i>%s</i>';
$lang['news_archive'] = 'Archives';
$lang['page'] = 'Page';

#
#-----[ OPEN ]---------------------------------
#
template/default/home.html

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
{whos_online}
#
#-----[ BEFORE, ADD ]------------------------------------------
#
Code: [Select]
<table width="450" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="head1">
      <table width="100%" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td class="head1">{news_main}</td>
          <td class="head1" align="right" height="20">{news_archives}</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="head1" colspan="2">{news}</td>
  </tr>
</table>
<br />

#
#-----[ OPEN ]---------------------------------
#
lang/english/admin.php

#
#-----[ FIND ]---------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
Code: [Select]
/*-- Setting-Group 8 --*/
$setting_group[8] = "News";
$news_display_optionlist = array(
  "1" => "Show the last 'X' news",
  "2" => "Show news of the last 'X' days",
);

$setting['news_home_display'] = "News display mode";
$setting['news_nb'] = "News number";
$setting['news_nb_days'] = "Days number";
$setting['news_cutoff'] = "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 images (BB-Code) in news";
#
#-----[ OPEN ]---------------------------------
#
lang/french/admin.php

#
#-----[ FIND ]---------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
Code: [Select]
/*-- Setting-Group 8 --*/
$setting_group[8] = "Nouvelles";
$news_display_optionlist = array(
  "1" => "Afficher les 'X' derničres nouvelles",
  "2" => "Afficher les nouvelles des 'X' derniers jours",
);

$setting['news_home_display'] = "Mode d'affichage des nouvelles";
$setting['news_nb'] = "Nombre de nouvelles";
$setting['news_nb_days'] = "Nombre de jours";
$setting['news_cutoff'] = "Nombre de jours ou la nouvelle est considérée comme 'nouvelle'";
$setting['news_html'] = "Autoriser le HTML dans les nouvelles";
$setting['news_bbcode'] = "Autoriser le BB-Code dans les nouvelles";
$setting['news_bbcodeimg'] = "Autoriser les images (BB-Code) dans les nouvelles";
#
#-----[ OPEN ]---------------------------------
#
admin/settings.php

#
#-----[ FIND ]---------------------------------
#
Code: [Select]
show_setting_row("highlight_admin", "radio");
#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: [Select]
show_table_separator($setting_group[8], 2, "#setting_group_8");
show_setting_row("news_home_display", "show_news_display_options");
show_setting_row("news_nb");
show_setting_row("news_nb_days");
show_setting_row("news_cutoff");
show_setting_row("news_html", "radio");
show_setting_row("news_bbcode", "radio");
show_setting_row("news_bbcodeimg", "radio");
#
#-----[ FIND ]---------------------------------
#
Code: [Select]
// end of functions
#
#-----[ BEFORE, ADD ]------------------------------------------
#
Code: [Select]
function show_news_display_options($setting_name, $setting_value) {
  global $news_display_optionlist;
  foreach ($news_display_optionlist as $key => $val) {
    echo "<input type=\"radio\" name=\"setting_item[".$setting_name."]\" value=\"$key\"";
    if ($setting_value == $key) {
      echo " checked=\"checked\"";
    }
    echo "> ".$val."<br />";
  }
}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

#
#-----[ DATABASE UPDATE ]------------------------------------------
#

Open a web browser and open the page http://your_domain/4images_dir/install_news.php

and thanks a lot to theOracle which saved the 4images_news.zip file on his computer
TheOracle also have done a addon --> http://www.4homepages.de/forum/index.php?topic=9059
Beati pauperi spiritus

4images 1.7 // My Installed Mods


TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #1 on: July 28, 2005, 01:35:42 PM »
*** IMPORTANT BUG FOUND AND CORRECTED ABOVE. ***

For users who already installed this MOD yesterday, it is imperative that you make the following modifications from

your index.php file due to sessions issues from the archives page. This was the main reason why numerous users has reported a bug in that page in the past.

Find :

Quote

"news_archives" => $lang['news_archive'],


and strongly replace with :

Code: [Select]

"news_archives" => "<a href=\"".$site_sess->url(ROOT_PATH."news.php")."\" class=\"link\">".$lang['news_archive']."</a>",


Then, in your templates/<your_template>/home.html file,

find :

Quote

<td class="head1" align="right"><a class="head1" href="news.php">{news_archives}</a></td>


simply replace with :

Code: [Select]

<td class="head1" align="right" height="20">{news_archives}</td>


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD]Another Simple News Publishing Mod
« Reply #2 on: July 30, 2005, 06:41:56 PM »
and strongly replace with :

Code: [Select]

"news_archives" => "<a href=\"".$site_sess->url(ROOT_PATH."news.php?sessionid=".$session_info['session_id'])."\" class=\"link\">".$lang['news_archive']."</a>",


Should be:
Code: [Select]
"news_archives" => "<a href=\"".$site_sess->url(ROOT_PATH."news.php")."\" class=\"link\">".$lang['news_archive']."</a>",
Your first three "must do" before you ask a question:
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)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline pkitty

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #3 on: August 01, 2005, 10:10:38 PM »
This is on the new mod is that correct posted by Vano? Not the older ones, right?   ....I dont seem to be having any issues, so do I need to change mine?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD]Another Simple News Publishing Mod
« Reply #4 on: August 02, 2005, 12:06:01 AM »
This is on the new mod is that correct posted by Vano? Not the older ones, right? ....I dont seem to be having any issues, so do I need to change mine?
block the cookies and u'll see the issue: two sessionid in the url for news archive
Your first three "must do" before you ask a question:
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)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #5 on: August 02, 2005, 12:12:28 AM »
Quote

block the cookies and u'll see the issue: two sessionid in the url for news archive


Since the answer above is now clean, modifications will be made above as the first post will be arranged shortly as well.

Offline pkitty

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #6 on: August 03, 2005, 01:26:21 AM »
Okay, I went and did this....and I see that there is a news/edit news in the control panel, but when I click on it, I now get a huge list of weird errors....

this was the mod for news that I installed http://www.4homepages.de/forum/index.php?topic=5142.0  should I not have done that....  *shakes Head*

TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #7 on: August 03, 2005, 01:54:50 AM »
Quote

this was the mod for news that I installed http://www.4homepages.de/forum/index.php?topic=5142.0  should I not have done that....  *shakes Head*


These are two seperated MODs which must not be used together.

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #8 on: August 03, 2005, 08:30:36 PM »
How can I edit the text colors in the tag that is using {news}
I tried editing news_bit.html (works for the Archives) But news_show.html doesn't do anything. What am I doing wrong?

TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #9 on: August 03, 2005, 10:26:18 PM »
Quote

How can I edit the text colors in the tag that is using {news}


These classes are located in index.php and news.php file.

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #10 on: August 04, 2005, 11:31:00 AM »
Quote

How can I edit the text colors in the tag that is using {news}


These classes are located in index.php and news.php file.

uhm. I found the code. But what should I change exatly? :oops:

TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #11 on: August 04, 2005, 01:45:31 PM »
From index.php file :

Quote

$news .= "<tr class=\"imagerow1\">\n";
    $news .= "<td width=\"100%\" valign=\"top\">\n";
    $new_is_new = ($image_row['news_date'] > time() - ((isset($config['news_cutoff']))?$config['news_cutoff']:3)*86400);
    $news .= "<b>".$image_row['news_title']."</b>  -- Posté par <b>".$image_row['user_name']."</b> le <i>".format_date($config['date_format']." ".$config['time_format'], $image_row['news_date'])."</i>";
    $news .= "\n</td>\n";
    $news .= "</tr>\n";

    $news .= "<tr class=\"imagerow2\">\n";
    $news .= "<td width=\"100%\" valign=\"top\">\n<br/>";
    $news .= format_text($image_row['news_text'], ((isset($config['news_html']))?$config['news_html']:0), 0, ((isset($config['news_bbcode']))?$config['news_bbcode']:1), ((isset($config['news_bbcodeimg']))?$config['news_bbcodeimg']:1));
    $news .= "<br/><br/>\n</td>\n";
    $news .= "</tr>\n";


Simply change the bolded statement.

Note: There's no classes in news.php file. ;)

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #12 on: August 04, 2005, 02:25:44 PM »
ohh yea my bad he ;D Thanks.

One last question, how come I can't change the bold font for the user who posted the news. The headline did have <b></b> but not the  $image_row['user_name'] :oops:

TheOracle

  • Guest
Re: [MOD]Another Simple News Publishing Mod
« Reply #13 on: August 04, 2005, 02:30:11 PM »
I knew I should of left the rest of my message on my recent post.

The answer on this is that I took this peace ' from the very original post ' comparing on the top. As you can see, the quoted part I sent does actually includes the bolded tags on the $image_row['user_name']. ;)

Offline Xaero

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: [MOD]Another Simple News Publishing Mod
« Reply #14 on: August 07, 2005, 02:48:40 PM »
It works fine for me exept the MOD settings cannot be saved thus I cannot use HTML or BB-code in news. Though other options exept the Mod's work well