Author Topic: W.I.P. - MOD- Articles and Article Categories  (Read 22685 times)

0 Members and 1 Guest are viewing this topic.

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
W.I.P. - MOD- Articles and Article Categories
« on: May 07, 2013, 10:13:25 PM »
This MOD is for creating Articles (typed text that can be News, Opinions, Articles, Blogs, etc) and Categories for them that are SEPARATE from the Image Categories.

What it does - It allows you to create Article categories to be displayed on the front page, and from there, create/write articles (or news, etc). The thumbnails of images are not used. Rather, the first piece of the Article, AKA the "snippet", is used as a thumbnail. It's stand-alone, so it does not interfere with the Image Categories and images. It does use comments that operate just like the Image comments. Editing, creation, deleting... all of it works just like the Image and regular categories.

Important - This MOD is not a full release yet. As the title of the thread says, it is a W.I.P. (Work In Progress). Feed back is needed, as I am requesting that you experts out there can look over the script(s) and see if there is any streamlining/clean-up that can be done. It IS fully functional as it currently is.

I also request that someone can make this Searchable.

WARNING!!!

This MOD modifies your database, so make a back-up first!!!

Let's get started -

I repeat: This MOD modifies your database, so make a back-up first!!!

STEP 1

Unzip the attached zip file. Upload all files to your 4images ROOT directory, maintaining the folder structure.

STEP 2

This file modifies your database, so make a back-up first!!! Once articles_install.php is uploaded to the ROOT directory, point your browser to it and run the script. Again, this file modifies your database, so make a back-up first!!!

STEP 3

Create these two folders in ROOT/data/
articles (CHMOD it to 777)
tmp_articles (CHMOD it to 777)

STEP 4

Open admin/admin_functions.php

Find:
?>

Add ABOVE:
include(ROOT_PATH.'admin/article_admin_functions.php');

STEP 5

Open admin/home.php

Find:
  $total_images 0;
  
$total_categories 0;
  foreach (
$cat_cache as $val) {
    
$total_categories++;
    if (isset(
$val['num_images'])) {
      
$total_images += $val['num_images'];
    }
  }


Add BELOW:
// Begin Article Mod
  
$total_articles 0;
  
$total_article_categories 0;
  foreach (
$article_cat_cache as $val) {
    
$total_article_categories++;
    if (isset(
$val['num_articles'])) {
      
$total_articles += $val['num_articles'];
    }
  }
// End Article Mod


STEP 6

Still in admin/home.php

Find:
//1
  
echo "<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td width=\"16%\"><b>".$lang['categories']."</b></td><td width=\"16%\">".$total_categories."</td>\n";
  
$size 0;
  echo 
"<td width=\"16%\"><b>".$lang['media_directory']."</b></td><td width=\"16%\">".format_file_size(get_dir_size(MEDIA_PATH))."</td>\n";
  echo 
"</tr>";

  
//2
  
echo "<tr class=\"".get_row_bg()."\">\n";

  
$sql "SELECT COUNT(*) as temp_images
          FROM "
.IMAGES_TEMP_TABLE;
  
$row $site_db->query_firstrow($sql);

  
$awaiting_validation preg_replace("/".$site_template->start."num_images".$site_template->end."/siU"$row['temp_images'], $lang['images_awaiting_validation']);
  
$awaiting_validation sprintf("<a href=\"".$site_sess->url("validateimages.php?action=validateimages")."\">%s</a>"$awaiting_validation);
  echo 
"<td width=\"16%\"><b>".$lang['images']."</b></td><td width=\"16%\">".$total_images." / ".$awaiting_validation."</td>\n";
  
$size 0;
  echo 
"<td width=\"16%\"><b>".$lang['thumb_directory']."</b></td><td width=\"16%\">".format_file_size(get_dir_size(THUMB_PATH))."</td>\n";
  echo 
"</tr>";

  
//3
  
echo "<tr class=\"".get_row_bg()."\">\n";


REPLACE WITH:
//1
  
echo "<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td width=\"16%\"><b>Image ".$lang['categories']."</b></td><td width=\"16%\">".$total_categories."</td>\n";
  
$size 0;
  echo 
"<td width=\"16%\"><b>Article ".$lang['categories']."</b></td><td width=\"16%\">".$total_article_categories."</td>\n";
  echo 
"</tr>";

  
//2
  
echo "<tr class=\"".get_row_bg()."\">\n";

  
$sql "SELECT COUNT(*) as temp_images
          FROM "
.IMAGES_TEMP_TABLE;
  
$row $site_db->query_firstrow($sql);

  
$awaiting_validation preg_replace("/".$site_template->start."num_images".$site_template->end."/siU"$row['temp_images'], $lang['images_awaiting_validation']);
  
$awaiting_validation sprintf("<a href=\"".$site_sess->url("validateimages.php?action=validateimages")."\">%s</a>"$awaiting_validation);
  
  echo 
"<td width=\"16%\"><b>".$lang['images']."</b></td><td width=\"16%\">".$total_images." / ".$awaiting_validation."</td>\n";
  
$size 0;

  
$sql "SELECT COUNT(*) as temp_articles
          FROM "
.ARTICLE_TEMP_TABLE;
  
$rowart $site_db->query_firstrow($sql);

  
$awaiting_validationart preg_replace("/".$site_template->start."num_articles".$site_template->end."/siU"$rowart['temp_articles'], $lang['articles_awaiting_validation']);
  
$awaiting_validationart sprintf("<a href=\"".$site_sess->url("validatearticles.php?action=validatearticles")."\">%s</a>"$awaiting_validationart);
  
  echo 
"<td width=\"16%\"><b>Articles</b></td><td width=\"16%\">".$total_articles." / ".$awaiting_validationart."</td>\n";
  echo 
"</tr>";
  
  
//3
  
echo "<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td width=\"16%\"><b>".$lang['media_directory']."</b></td><td width=\"16%\">".format_file_size(get_dir_size(MEDIA_PATH))."</td>\n";
  
$size 0;
  echo 
"<td width=\"16%\"><b>".$lang['thumb_directory']."</b></td><td width=\"16%\">".format_file_size(get_dir_size(THUMB_PATH))."</td>\n";
  echo 
"</tr>";

  
//4
  
echo "<tr class=\"".get_row_bg()."\">\n";


STEP 7

Open admin/index.php

Find:
show_nav_option($lang['nav_categories_add'], "categories.php?action=addcat");

Add BELOW:
          // Begin Article Mod
          
show_nav_header($lang['nav_artcategories_main']);
          
show_nav_option($lang['nav_artcategories_edit'], "article_categories.php?action=modifycats");
          
show_nav_option($lang['nav_artcategories_add'], "article_categories.php?action=addcat");
          
// End Article Mod


STEP 8

Still in admin/index.php

Find:
show_nav_option($lang['nav_images_resizer'], "resizer.php?action=selectoptions");

Add BELOW:
          // Begin Article Mod
          
show_nav_header($lang['nav_articles_main']);
          
show_nav_option($lang['nav_articles_edit'], "articles.php?action=modifyarticles");
          
show_nav_option($lang['nav_articles_add'], "articles.php?action=addarticles");
          
show_nav_option($lang['nav_articles_validate'], "validatearticles.php?action=validatearticles");
          
// End Article Mod


STEP 9

Still in admin/index.php

Find:
show_nav_option($lang['nav_comments_edit'], "comments.php?action=modifycomments");

Add BELOW:
show_nav_option($lang['nav_article_comments_edit'], "article_comments.php?action=modifycomments");

STEP 10

Still in admin/index.php

Find:
show_nav_option($lang['nav_general_stats'], "stats.php?action=resetstats");

Add BELOW:
show_nav_option($lang['nav_article_stats'], "article_stats.php?action=resetstats");

STEP 11

Open admin/settings.php

Find:
function show_cat_sort_select($setting_name$setting_value) {
  global 
$cat_sort_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach ( 
$cat_sort_optionlist as $k => $v ) {
    echo 
"<option value=\"".$k."\"";
    if (
$setting_value == $k) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$v."</option>\n";  
  }
  echo 
"</select>\n";
}


Add BELOW:
// Begin Article Mod
function show_article_cat_order_select($setting_name$setting_value) {
  global 
$article_cat_order_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach ( 
$article_cat_order_optionlist as $k => $v ) {
    echo 
"<option value=\"".$k."\"";
    if (
$setting_value == $k) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$v."</option>\n";  
  }
  echo 
"</select>\n";
}

function 
show_article_cat_sort_select($setting_name$setting_value) {
  global 
$article_cat_sort_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach ( 
$article_cat_sort_optionlist as $k => $v ) {
    echo 
"<option value=\"".$k."\"";
    if (
$setting_value == $k) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$v."</option>\n";  
  }
  echo 
"</select>\n";
}
// End Article Mod


STEP 12

Still in admin/settings.php

Find:
function show_image_sort_select($setting_name$setting_value) {
  global 
$image_sort_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach (
$image_sort_optionlist as $key => $val) {
    echo 
"<option value=\"$key\"";
    if (
$setting_value == $key) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$val."</option>";
  }
  echo 
"</select>";
}


Add BELOW:
// Begin Article Mod
function show_article_order_select($setting_name$setting_value) {
  global 
$article_order_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach (
$article_order_optionlist as $key => $val) {
    echo 
"<option value=\"$key\"";
    if (
$setting_value == $key) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$val."</option>";
  }
  echo 
"</select>";
}

function 
show_article_sort_select($setting_name$setting_value) {
  global 
$article_sort_optionlist;
  echo 
"<select name=\"setting_item[".$setting_name."]\">";
  foreach (
$article_sort_optionlist as $key => $val) {
    echo 
"<option value=\"$key\"";
    if (
$setting_value == $key) {
      echo 
" selected=\"selected\"";
    }
    echo 
">".$val."</option>";
  }
  echo 
"</select>";
}
// End Article Mod


STEP 13

Still in admin/settings.php

Find:
show_setting_row("num_subcats");

Add BELOW:
// Begin Article Mod
  
show_table_separator($setting_group[8], 2"setting_group_8");
  
show_setting_row("article_cat_order""show_article_cat_order_select");
  
show_setting_row("article_cat_sort""show_article_cat_sort_select");
  
show_setting_row("article_cat_cells");
  
show_setting_row("article_cat_table_width");
  
show_setting_row("article_cat_table_cellspacing");
  
show_setting_row("article_cat_table_cellpadding");
  
show_setting_row("num_artsubcats");
// End Article Mod


STEP 14

Still in admin/settings.php

Find:
show_setting_row("image_table_cellpadding");

Add BELOW:
// Begin Article Mod
  
show_table_separator($setting_group[9], 2"setting_group_9");
  
show_setting_row("article_order""show_article_order_select");
  
show_setting_row("article_sort""show_article_sort_select");
  
show_setting_row("article_new_cutoff");
  
show_setting_row("article_cells");
  
show_setting_row("default_article_rows");
  
show_setting_row("custom_article_row_steps");
  
show_setting_row("article_table_width");
  
show_setting_row("article_table_cellspacing");
  
show_setting_row("article_table_cellpadding");
// End Article Mod


STEP 15

Still in admin/settings.php

Find:
show_setting_row("upload_emails");

Add BELOW:
  show_setting_row("article_add_notify""radio");
  
show_setting_row("article_emails");


STEP 16

Still in admin/settings.php

Find:
show_setting_row("user_delete_comments""radio");

Add BELOW:
  show_setting_row("user_edit_article""radio");
  
show_setting_row("user_delete_article""radio");
  
show_setting_row("user_edit_article_comments""radio");
  
show_setting_row("user_delete_article_comments""radio");


STEP 17

Open includes/auth.php

Find:
?>

Add ABOVE:
include(ROOT_PATH.'includes/article_auth.php');

STEP 18

Open includes/contants.php

Find:
define('WORDMATCH_TABLE'$table_prefix.'wordmatch');

Add BELOW:
// Begin Articles Mod
define('ARTICLECATS_TABLE'$table_prefix.'articlecats');
define('ARTICLE_TABLE'$table_prefix.'article');
define('ARTICLE_TEMP_TABLE'$table_prefix.'article_temp');
define('COMMENTS_ARTICLE_TABLE'$table_prefix.'comments_article');
// End Articles Mod


STEP 19

Still in includes/contants.php

Find:
define('URL_ID''id');

Add BELOW:
// Begin Articles Mod
define('URL_ARTICLE_ID''article_id');
define('URL_ARTICLECAT_ID''cat_id');
define('URL_COMMENT_ARTICLE_ID''comment_article_id');
// End Articles Mod


STEP 20

Still in includes/contants.php

Find:
define('TEMPLATE_DIR''templates');

Add BELOW:
// Begin Articles Mod
define('ARTCAT_DIR''data/articles');
define('ARTCAT_TEMP_DIR''data/tmp_articles');
// End Articles Mod


STEP 21

Open includes/functions.php

Find:
?>

Add ABOVE:
include(ROOT_PATH.'includes/article_functions.php');

STEP 22

Open includes/page_header.php

Find:
$auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];

Add BELOW:
// Begin Article Mod
  
$total_articles 0;
  
$total_article_categories 0;
  foreach (
$article_cat_cache as $val) {
    
$total_article_categories++;
    if (isset(
$val['num_articles'])) {
      
$total_articles += $val['num_articles'];
    }
  }
// End Article Mod


STEP 23

Still in includes/page_header.php

Find:
 "page_top"        => false,

Add BELOW:
// Begin Article Mod
    
"page_article_categories" => false,
    
"page_article"    => false,
// End Article Mod


STEP 24

Still in includes/page_header.php

Find:
"top"        => false,

Add BELOW:
// Begin Article Mod
    
"article_categories" => false,
    
"article"    => false
// End Article Mod


STEP 25

Still in includes/page_header.php

Find:
"rss_url" => "",

Add ABOVE:
// Begin Article Mod
  
"url_article" => $site_sess->url(ROOT_PATH."article.php"),
  
"url_article_categories" => $site_sess->url(ROOT_PATH."article_categories.php"),
  
"url_addarticle" => (!empty($url_addarticle)) ? $site_sess->url($url_addarticle) : $site_sess->url(ROOT_PATH."article_editing.php?action=addarticleform"),
  
"article_nails" => "",
  
"total_article_categories" => $total_article_categories,
  
"total_articles" => $total_articles,
// End Article Mod


STEP 26

Still in includes/page_header.php

Find:
"direction" => $lang['direction'],

Add BELOW:
// Begin Article Mod
  
"lang_image_stats" => $lang['image_stats'],
  
"lang_article_stats" => $lang['article_stats'],
  
"lang_new_articles" => $lang['new_articles'],
  
"lang_top_articles" => $lang['top_articles'],
  
"lang_articles_per_page" => $lang['articles_per_page'],
  
"lang_home" => $lang['home'],
  
"lang_articles" => $lang['articles'],
  
"lang_article_categories" => $lang['article_categories'],
  
"lang_article_site_stats" => $lang['article_site_stats'],
// End Article Mod


STEP 27

Still in includes/page_header.php

Find:
unset($category_dropdown_form);

Add BELOW:
// Begin Article Mod
if (!$cache_enable) {
    
$article_category_dropdown_selfjump get_article_category_dropdown($cat_id1);
} else {
  
$cache_id create_cache_id(
    
'article_data.dropdown_selfjump',
    array(
      
$user_info[$user_table_fields['user_id']],
      
$config['template_dir'],
      
$config['language_dir']
    )
  );

  if (!
$article_category_dropdown_selfjump get_cache_file($cache_id)) {
    
// Always append session id if cache is enabled
    
$old_session_mode $site_sess->mode;
    
$site_sess->mode 'get';

    
// Set $cat_id to 0 to ensure that no category is selected
    
$article_category_dropdown_selfjump get_article_category_dropdown(01);

    
$site_sess->mode $old_session_mode;

    
save_cache_file($cache_id$article_category_dropdown_selfjump);
  }
}

$site_template->register_vars("article_category_dropdown_selfjump"$article_category_dropdown_selfjump);
unset(
$article_category_dropdown_selfjump);

// -------------------------------------
if (!$cache_enable) {
    
$article_category_dropdown_form $site_template->parse_template("article_category_dropdown_form");
} else {
  
$cache_id create_cache_id(
    
'article_data.dropdown_form',
    array(
      
$user_info[$user_table_fields['user_id']],
      
// $cat_id, // uncomment if the current category should be selected, will increase the number of cache files
      
$config['template_dir'],
      
$config['language_dir']
    )
  );

  if (!
$article_category_dropdown_form get_cache_file($cache_id)) {
    
// Always append session id if cache is enabled
    
$old_session_mode $site_sess->mode;
    
$site_sess->mode 'get';

    
$article_category_dropdown_form $site_template->parse_template("article_category_dropdown_form");

    
$site_sess->mode $old_session_mode;

    
save_cache_file($cache_id$article_category_dropdown_form);
  }
}

$site_template->register_vars("article_category_dropdown_form"$article_category_dropdown_form);
unset(
$article_category_dropdown_form);
// End Article Mod


STEP 28

Still in includes/page_header.php

Find:
    $msg $lang['voting_error'];
  }
}


Add BELOW:
if ($action == "ratearticle" && $id) {
  
$rating intval($HTTP_POST_VARS['rating']);
  
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME "4images_";
  
$cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? explode(" "stripslashes((string)$HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if (
$rating && $rating <= MAX_RATING && $id) {
    if (!isset(
$session_info['rated_arts'])) {
      
$session_info['rated_arts'] = $site_sess->get_session_var("rated_arts");
    }
    
$split_list = array();
    if (!empty(
$session_info['rated_arts'])) {
      
$split_list explode(" "$session_info['rated_arts']);
    }
    if (!
in_array($id$split_list) && !in_array($id$cookie_rated)) {
      
$session_info['rated_arts'] .= " ".$id;
      
$session_info['rated_arts'] = trim($session_info['rated_arts']);
      
$site_sess->set_session_var("rated_arts"$session_info['rated_arts']);
      
$cookie_rated[] = $id;
      
$cookie_expire time() + 60 60 24 4;
      
setcookie($cookie_name.'rated'implode(" "$cookie_rated), $cookie_expireCOOKIE_PATHCOOKIE_DOMAINCOOKIE_SECURE);
      
update_article_rating($id$rating);
      
$msg $lang['voting_success'];
    }
    else {
      
$msg $lang['already_voted'];
    }
  }
  else {
    
$msg $lang['voting_error'];
  }
}


STEP 29

Open global.php

Find:
$auth_cat_sql = array();

Add BELOW:
// Begin Articles Mod
$article_cat_cache = array();
$article_cat_parent_cache = array();
$new_article_cache = array();
$additional_article_fields = array();
$auth_art_cat_sql = array();
// End Articles Mod


STEP 30

Still in global.php

Find:
$cache_page_rss        1;

Add BELOW:
// Begin Articles Mod
$cache_page_articlecats 1;
// End Articles Mod


STEP 31

Still in global.php

Find:
$captcha_filter_bg           1;

Add BELOW:
// Begin Articles Mod
$captcha_enable_addarticle       1;
// End Articles Mod


STEP 32

Still in global.php

Find:
$cache_page_rss        0;

Add BELOW:
// Begin Articles Mod
  
$cache_page_articlecats 0;
// End Articles Mod


STEP 33

Still in global.php

Find:
$captcha_enable_postcards    0;

Add BELOW:
  // Begin Articles Mod
  
$captcha_enable_addarticle       0;
  
// End Articles Mod


STEP 34

Still in global.php

Find:
else {
  
$search_new_images 0;
}


Add BELOW:
// Begin Articles Mod
if (isset($HTTP_GET_VARS[URL_ARTICLECAT_ID]) || isset($HTTP_POST_VARS[URL_ARTICLECAT_ID])) {
  
$cat_id = (isset($HTTP_POST_VARS[URL_ARTICLECAT_ID])) ? intval($HTTP_POST_VARS[URL_ARTICLECAT_ID]) : intval($HTTP_GET_VARS[URL_ARTICLECAT_ID]);
}
else {
  
$cat_id 0;
}

if (isset(
$HTTP_GET_VARS[URL_ARTICLE_ID]) || isset($HTTP_POST_VARS[URL_ARTICLE_ID])) {
  
$article_id = (isset($HTTP_POST_VARS[URL_ARTICLE_ID])) ? intval($HTTP_POST_VARS[URL_ARTICLE_ID]) : intval($HTTP_GET_VARS[URL_ARTICLE_ID]);
}
else {
  
$article_id 0;
}
// End Articles Mod


STEP 35

Still in global.php

Find:
$self_url .= "?".URL_CAT_ID."=".$cat_id;
  }


Add BELOW:
// Begin Articles Mod
  
elseif (preg_match("/article.php/"$self_url) && !preg_match("/[?|&]".URL_ARTICLE_ID."=[^?|&]*/"$self_url) && $article_id) {
    
$self_url .= "?".URL_ARTICLE_ID."=".$article_id;
  }
  elseif (
preg_match("/article_categories.php/"$self_url) && !preg_match("/[?|&]".URL_ARTICLECAT_ID."=[^?|&]*/"$self_url)) {
    
$self_url .= "?".URL_ARTICLECAT_ID."=".$cat_id;
  }
// End Articles Mod


STEP 36

Still in global.php

Find:
define('ICON_PATH'ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");

Add BELOW:
// Begin Articles Mod
define('ARTCAT_PATH'ROOT_PATH.ARTCAT_DIR);
define('ARTCAT_TEMP_PATH'ROOT_PATH.ARTCAT_TEMP_DIR);
// End Articles Mod


STEP 37

Still in global.php

Find:
$new_cutoff time() - (60 60 24 $config['new_cutoff']);

Add BELOW:
// Begin Articles Mod

  
$sql "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewarticle, auth_addarticle, auth_directaddarticle, auth_vote, auth_readcomment, auth_postcomment
          FROM "
.ARTICLECATS_TABLE."
          ORDER BY cat_order, cat_name ASC"
;
  
$result $site_db->query($sql);

  while (
$article_row $site_db->fetch_array($result)) {
    
$article_cat_cache[$article_row['cat_id']] = $article_row;
    
$article_cat_parent_cache[$article_row['cat_parent_id']][] = $article_row['cat_id'];
  }
  
$site_db->free_result();

// End Articles Mod


STEP 38

Still in global.php

Find:
//end if GET_CACHES

Add ABOVE:
// Begin Articles Mod

  
$sql "SELECT cat_id, COUNT(article_id) AS new_articles
          FROM "
.ARTICLE_TABLE."
          WHERE article_active = 1 AND article_date >= 
$new_cutoff
          GROUP BY cat_id"
;
  
$result $site_db->query($sql);

  while (
$article_row $site_db->fetch_array($result)) {
    
$new_article_cache[$article_row['cat_id']] = $article_row['new_articles'];
  }
  
$site_db->free_result();
  
  
//--------------------------------------

  
$sql "SELECT cat_id, COUNT(*) AS num_articles
          FROM "
.ARTICLE_TABLE."
          WHERE article_active = 1
          GROUP BY cat_id"
;
  
$result $site_db->query($sql);

  while (
$article_row $site_db->fetch_array($result)) {
    
$article_cat_cache[$article_row['cat_id']]['num_articles'] = $article_row['num_articles'];
  }
  
$site_db->free_result();
  
// End Articles Mod


STEP 39

Open index.php

Find:
$templates_used 'home,category_bit,

Add AFTER:
article_category_bit,article_nail_bit,

STEP 40

Still in index.php

Find:
$user_access get_permission();

REPLACE WITH:
$user_access get_permission() && get_permissions();

STEP 41

Still in index.php

Find:
unset($new_images);

Add BELOW:
//-----------------------------------------------------
//--- Show Article Categories ---------------------------------
//-----------------------------------------------------
$article_categories get_article_categories(0);
if (!
$article_categories)  {
  
$article_categories $lang['no_categories'];
}
$site_template->register_vars("article_categories"$article_categories);
unset(
$article_categories);


//-----------------------------------------------------
//--- Show New Articles ---------------------------------
//-----------------------------------------------------

$arttable_width ceil(intval($config['article_table_width']) / $config['article_cells']);
if ((
substr($config['article_table_width'], -1)) == "%") {
  
$arttable_width .= "%";
}

$additional_artsql "";
if (!empty(
$additional_article_fields)) {
  foreach (
$additional_article_fields as $key => $val) {
    
$additional_artsql .= ", a.".$key;
  }
}

$num_new_articles $config['article_cells'];
$sql "SELECT a.article_id, a.cat_id, a.user_id, a.article_title, a.snippet, a.article_words, a.article_date, a.article_active, a.article_allow_comments, a.article_comments, a.article_votes, a.article_rating, a.article_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.ARTICLE_TABLE." a,  ".ARTICLECATS_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = a.user_id)
        WHERE a.article_active = 1 AND c.cat_id = a.cat_id AND a.cat_id NOT IN ("
.get_auth_art_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY a.article_date DESC
        LIMIT 
$num_new_articles";
$result $site_db->query($sql);
$article_num_rows $site_db->get_numrows($result);

if (!
$article_num_rows)  {
  
$new_articles "<table width=\"".$config['article_table_width']."\" border=\"0\" cellpadding=\"".$config['article_table_cellpadding']."\" cellspacing=\"".$config['article_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_articles .= $lang['no_new_articles'];
  
$new_articles .= "</td></tr></table>";
}
else  {
  
$new_articles "<table width=\"".$config['article_table_width']."\" border=\"0\" cellpadding=\"".$config['article_table_cellpadding']."\" cellspacing=\"".$config['article_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$article_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_articles .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_articles .= "<td width=\"".$arttable_width."\" valign=\"top\">\n";

    
show_article($article_row);
    
$new_articles .= $site_template->parse_template("article_nail_bit");
    
$new_articles .= "\n</td>\n";
    
$count++;
    if (
$count == $config['article_cells']) {
      
$new_articles .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['article_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_articles .= "<td width=\"".$arttable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_articles .= "</tr>\n";
    }
  }
  
$new_articles .= "</table>\n";
// end else

$site_template->register_vars("new_articles"$new_articles);
unset(
$new_articles);


STEP 42

Open lang/(your language)/admin.php (sorry, no translations!)

Find:
$lang['file_not_found'] = "File not found";

Add BELOW:
// Begin Articles Mod
$lang['article'] = "Article";
$lang['articles'] = "Articles";
$lang['delete_article_confirm'] = "Do you want to delete this article? All attached comments will be deleted as well.";
$lang['article_delete_success'] = "Article deleted";
$lang['article_delete_error'] = "Error deleting article";
$lang['article_perms'] = "Permission Masks";
$lang['articles_delete_success'] = "Articles deleted";
$lang['show_only_topic'] = "Show Only in Topic";
$lang['show_front_page'] = "Show on Front Page";
$lang['nav_artcategories_main'] = "Article Categories";
$lang['nav_artcategories_edit'] = "Edit Article categories";
$lang['nav_artcategories_add'] = "Add Article categories";
$lang['articles_awaiting_validation'] = "<b>{num_articles}</b> articles awaiting validation";
$lang['nav_articles_main'] = "Articles";
$lang['nav_articles_edit'] = "Edit Articles";
$lang['nav_articles_add'] = "Add Articles";
$lang['nav_article_stats'] = "Reset Article Stats";
$lang['nav_articles_validate'] = "Validate Articles";
$lang['nav_article_comments_edit'] = "Edit Article comments";
$lang['field_article_name'] = "Article Title";
$lang['field_article_title'] = "Article Title";
$lang['field_article_id_contains'] = "Article ID contains";
$lang['field_article_title_contains'] = "Article name contains";
$lang['field_snippet_contains'] = "Snippet contains";
$lang['field_article_contains'] = "Article contains";
$lang['field_snippet'] = "Snippet Text";
$lang['field_article'] = "Secondary Text";
$lang['field_article_words'] = "Secondary Text";
$lang['field_article_file_contains'] = "Image file contains";
$lang['field_article_category'] = "Article Category";
$lang['auth_viewarticle'] = "View Article";
$lang['auth_addarticle'] = "Add Article";
$lang['auth_directaddarticle'] = "Direct Article Add";
$lang['no_article_found'] = "Articles do not have image thumbs.";
// End Articles Mod


STEP 43

Still in lang/(your language)/admin.php (sorry, no translations!)

Find:
?>

Add ABOVE:
/*-- Setting-Group 8 --*/
$setting_group[8]="Article Category settings";
$setting['article_cat_order'] = "Sort categories by";
$article_cat_order_optionlist = array(
    
'cat_order'   => 'Default',
    
'cat_name'    => 'Name',
    
'cat_id'      => 'Date',
);
$setting['article_cat_sort'] = "Ascending/Descending";
$article_cat_sort_optionlist = array(
    
"ASC"  => "Ascending",
    
"DESC" => "Descending"
);
$setting['article_cat_cells'] = "Number of table cells";
$setting['article_cat_table_width'] = "Table width<br /><span class=\"smalltext\">absolute width or percentage</span>";
$setting['article_cat_table_cellspacing'] = "Cellspacing";
$setting['article_cat_table_cellpadding'] = "Cellpadding";
$setting['num_artsubcats'] = "Number of subcategories";

/*-- Setting-Group 9 --*/
$setting_group[9]="Article settings";
$setting['article_order'] = "Sort articles by";
$article_order_optionlist = array(
  
"article_title"      => "Name",
  
"article_date"      => "Date",
  
"image_votes"     => "Votes",
  
"image_rating"    => "Rating",
  
"image_hits"      => "Hits"
);
$setting['article_sort'] = "Ascending/Descending";
$article_sort_optionlist = array(
  
"ASC"  => "Ascending",
  
"DESC" => "Descending"
);
$setting['article_new_cutoff'] = "Number of days each article is marked as new";
$setting['article_cells'] = "Article table cells";
$setting['default_article_rows'] = "Article table rows";
$setting['custom_article_row_steps'] = "Number of dropdown options (allowing users to choose the number of articles per page)";
$setting['article_table_width'] = "Table width<br /><span class=\"smalltext\">absolute width or percentage</span>";
$setting['article_table_cellspacing'] = "Cellspacing";
$setting['article_table_cellpadding'] = "Cellpadding";


STEP 44

Open lang/(your language)/main.php (sorry, no translations!)

Find:
?>

Add ABOVE:
// Begin Articles Mod
$lang['articles'] = "Articles";
$lang['article_categories'] = "Article Categories";
$lang['snippet'] = "Snippet";
$lang['article_words'] = "Article Words";
$lang['field_snippet'] = "Snippet";
$lang['field_article'] = "Article";
$lang['field_article_title'] = "Article Title";
$lang['article_add_success'] = "Article added";
$lang['article_add_error'] = "Article Add Error!";
$lang['article_title_exists'] = "Title Exists!";
$lang['article_edit_success'] = "Article Edited!";
$lang['article_edit_error'] = "Article Editing Error!";
$lang['art_in_last'] = "article in last";
$lang['hours'] = "hours";
$lang['arts_in_last'] = "articles in last";
$lang['read_more'] = "read more";
$lang['mail_friend'] = "Mail to a Friend";
$lang['no_article_results'] = "No News to Display";
$lang['no_articles'] = "There are no articles in this category.";
$lang['no_article_txt'] = "There are no news stories to display.  There may be no news for this topic or you do not have access to this area.";
$lang['words'] = "words";
$lang['article_delete'] = "Delete article";
$lang['article_delete_success'] = "Article deleted";
$lang['article_delete_error'] = "Error deleting article";
$lang['article_delete_confirm'] = "Do you want to delete this article?";
$lang['post_article'] = "Post Article";
$lang['article_title'] = "Article Title";
$lang['article_edit'] = "Article Edit";
$lang['article_directory'] = "Article Directory";
$lang['articles_per_page'] = "Articles Per Page:";
$lang['image_stats'] = "Images:";
$lang['article_stats'] = "Articles:";
$lang['new_articles'] = "New Articles";
$lang['article_added_by'] = "Author:";
$lang['prev_article'] = "Previous article:";
$lang['next_article'] = "Next article:";
$lang['article_allow_comments'] = "Allow comments:";
$lang['user_addarticle'] = "Add Article";
$lang['new_article_emailsubject'] = "New Article Added to {site_name}";
$lang['new_addarticle_validate_desc'] = "Your article will be validated once it has been reviewed.";
$lang['no_new_articles'] = "Currently there are no new articles.";
$lang['article_site_stats'] = "<b>{total_articles}</b> Articles in <b>{total_article_categories}</b> Article Categories.";
// End Articles Mod


STEP 45

Open templates/(ALL VERSIONS of templates)/home.html

Find:
<hr size="1" />

Add BELOW:
                  {if article_categories}
                  <
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_article_categories}</td>
                          </
tr>
                          <
tr
                            <
td class="row2" valign="top">{article_categories}</td>
                          </
tr>
                        </
table>
                      </
td>
                    </
tr>
                  </
table>
                  <
br />
                  {endif 
article_categories}{lang_article_site_stats}
	
  <
br />
                  <
br />
                  <
table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <
tr
                      <
td class="head1"
                        <
table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <
tr
                            <
td class="head1" valign="top">{lang_articles}</td>
                          </
tr>
                        </
table>
                      </
td>
                    </
tr>
                    <
tr
                      <
td class="head1">{new_articles}</td>
                    </
tr>
                  </
table>
                  <
br />


STEP 46

Still in templates/(ALL VERSIONS of templates)/home.html

Find:
<td>{category_dropdown_form}</td>

Add BELOW:
<td align="center">{article_category_dropdown_form}</td>

And that's it. A nice, short, 46 step MOD (please note the humor there :D) Again, feedback welcome.
« Last Edit: May 30, 2013, 05:12:42 AM by Warrior »

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #1 on: May 12, 2013, 04:01:04 AM »
Wow. 0 downloads of the install files... telling me no one has tried this :(

Anyways, here are a couple of options for the front page.

Instead of showing the article "thumbs" in columns, like the New Images, this let's you put ONE article "thumb" in a row.

Open index.php

Find:
$num_new_articles $config['article_cells'];

Change to:
$num_new_articles $config['default_article_rows'];

What the above does is change from how many ACROSS will show TO how many DOWN will show. You can also place a hard number, like '10', instead of 'default_article_rows'.

Now go to your Admin CP/Settings and change the "Article table cells" to 1.

Now then...

You might also want to have one particular Article Category showing above the others, for example-

News

Then after that
Second
Third
Fourth categories, etc.

Find:
WHERE a.article_active AND c.cat_id a.cat_id AND a.cat_id NOT IN (".get_auth_art_cat_sql("auth_viewcat", "NOTIN").")

Replace with:
WHERE a.article_active AND c.cat_id a.cat_id AND a.cat_id IN ('1') AND a.cat_id NOT IN (".get_auth_art_cat_sql("auth_viewcat", "NOTIN").")

The '1' in AND a.cat_id IN ('1') is whichever category ID you want the article thumbs to draw from.

If you want more categories to show after that one, then do the following ONLY IF YOU HAVE DONE THE ABOVE REGARDING LIMITING CATEGORIES:

Find:

unset($new_articles);


Add AFTER:
//-----------------------------------------------------
//--- Show New Articles 1 ---------------------------------
//-----------------------------------------------------

$arttable_width ceil(intval($config['article_table_width']) / $config['article_cells']);
if ((
substr($config['article_table_width'], -1)) == "%") {
  
$arttable_width .= "%";
}

$additional_artsql "";
if (!empty(
$additional_article_fields)) {
  foreach (
$additional_article_fields as $key => $val) {
    
$additional_artsql .= ", a.".$key;
  }
}

$num_new_articles1 $config['default_article_rows'];
$sql "SELECT a.article_id, a.cat_id, a.user_id, a.article_title, a.snippet, a.article_words, a.article_date, a.article_active, a.article_allow_comments, a.article_comments, a.article_votes, a.article_rating, a.article_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.ARTICLE_TABLE." a,  ".ARTICLECATS_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = a.user_id)
        WHERE a.article_active = 1 AND c.cat_id = a.cat_id AND a.cat_id IN ('2','3') AND a.cat_id NOT IN ("
.get_auth_art_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY a.article_date DESC
        LIMIT 
$num_new_articles1";
$result $site_db->query($sql);
$article_num_rows $site_db->get_numrows($result);

if (!
$article_num_rows)  {
  
$new_articles1 "<table width=\"".$config['article_table_width']."\" border=\"0\" cellpadding=\"".$config['article_table_cellpadding']."\" cellspacing=\"".$config['article_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_articles1 .= $lang['no_new_articles'];
  
$new_articles1 .= "</td></tr></table>";
}
else  {
  
$new_articles1 "<table width=\"".$config['article_table_width']."\" border=\"0\" cellpadding=\"".$config['article_table_cellpadding']."\" cellspacing=\"".$config['article_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$article_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_articles1 .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_articles1 .= "<td width=\"".$arttable_width."\" valign=\"top\">\n";

    
show_article($article_row);
    
$new_articles1 .= $site_template->parse_template("article_nail_bit");
    
$new_articles1 .= "\n</td>\n";
    
$count++;
    if (
$count == $config['article_cells']) {
      
$new_articles1 .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['article_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_articles1 .= "<td width=\"".$arttable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_articles1 .= "</tr>\n";
    }
  }
  
$new_articles1 .= "</table>\n";
// end else

$site_template->register_vars("new_articles1"$new_articles1);
unset(
$new_articles1);


Note in this added scripting, the AND a.cat_id IN ('2','3') has different category ID's listed. Change them to whatever categories you want.

If you just did the above, then you'll need to open templates/YOUR TEMPLATES/home.html

Find:

                  
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <
tr
                      <
td class="head1"
                        <
table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <
tr
                            <
td class="head1" valign="top">{lang_articles}</td>
                          </
tr>
                        </
table>
                      </
td>
                    </
tr>
                    <
tr
                      <
td class="head1">{new_articles}</td>
                    </
tr>
                  </
table>
                  <
br />


Add AFTER:

                  
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <
tr
                      <
td class="head1"
                        <
table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <
tr
                            <
td class="head1" valign="top">{lang_articles}</td>
                          </
tr>
                        </
table>
                      </
td>
                    </
tr>
                    <
tr
                      <
td class="head1">{new_articles1}</td>
                    </
tr>
                  </
table>
                  <
br />


Enjoy.
« Last Edit: May 12, 2013, 05:17:23 PM by Warrior »

Rembrandt

  • Guest
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #2 on: May 12, 2013, 05:57:02 AM »
Hi!
First Thank You for sharing this mod, you're right, so many people want/wanted a Mod.
At the moment I can not test this, when I installed this modification, I will understand why he is so long.  :)

mfg Andi

p.s.: I hope their code is displayed correctly, if they are not the right tags for PHP using.

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #3 on: May 12, 2013, 07:41:30 AM »
p.s.: I hope their code is displayed correctly, if they are not the right tags for PHP using.


Hi Andi.

You confused me here... not the right tags for PHP using?

Rembrandt

  • Guest
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #4 on: May 12, 2013, 08:31:25 AM »
i mean this
[ php ]
..your php code...
[ /php ]

you use in your post for php:
[ code ]
..your php code..
[ / code]

I'm not sure if everything is displayed correctly in the forum.
example from v@no:
Code: [Select]
RewriteRule ^lightbox\.([0-9]+)\.htm$ lightbox.php?page=$1&%{QUERY_STRING}same code but displays different (no backslashes):
RewriteRule ^lightbox\.([0-9]+)\.htmlightbox.php?page=$1&%{QUERY_STRING}
see the difference, the backslash is not displayed.
« Last Edit: May 12, 2013, 08:46:54 AM by Rembrandt »

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #5 on: May 12, 2013, 05:09:58 PM »
Oh! Ok. I'll edit it.

Thanks!

Offline kar76

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #6 on: May 29, 2013, 07:56:54 PM »
Few suggestions

1. Snippet Text also show on main article when click read more. It should not included in main article.
2. Its better if Snippet extract from main article (Secondary Text), top few lines.
3. When add article Secondary Text for admin and Article Words for user must use WYSIWYG editor instead plain editor.
3. keywords or tags section absent for articles.

If find more will tell you  :)

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #7 on: May 29, 2013, 10:02:16 PM »
Few suggestions

1. Snippet Text also show on main article when click read more. It should not included in main article.
2. Its better if Snippet extract from main article (Secondary Text), top few lines.

The snippet is a part of the over-all article. If you want to eliminate it from the main article, then you just remove the snippet portion of the template for article. Having said that, I have made a slight modification for a character count that shows on the thumb on the home page and the categories page. See below this.

3. When add article Secondary Text for admin and Article Words for user must use WYSIWYG editor instead plain editor.

The basic 4images doesn't have that installed. That is a different MOD.

3. keywords or tags section absent for articles.

As I said in the initial posting, which has to do with the keywords/tags-
Quote
I also request that someone can make this Searchable.

And thanks for checking it out.

These two files will be replaced into the zip, so anyone downloading AFTER this posting date need NOT do these steps.

Open includes/article_functions.php

Find:
"snippet" => $snippet,

Add below:
    "thumb_text"  => (!empty($article_row['snippet'])) ? format_text(((strlen($article_row['snippet']) > 400) ? substr($article_row['snippet'], 0350)."..." $article_row['snippet']), 101) : REPLACE_EMPTY,

Adjust the numbers to fit how many characters you want to show on the front page before the read more kicks in.

Open templates (all versions of your templates)/article_nail_bit.html
Find:
{snippet}

replace with:
{thumb_text}
« Last Edit: May 30, 2013, 05:24:00 AM by Warrior »

Offline kar76

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #8 on: May 30, 2013, 09:01:16 AM »
Quote
The basic 4images doesn't have that installed. That is a different MOD.

Yes its diffrent thing, but you create this mod you better know where and how to add WYSIWYG editor in this mode. Once i tried to change 4images for article but mod add WYSIWYG editor in user section not in admin section for add article etc. People who are not coder can not do this. A light WYSIWYG editor will be good enough

Quote
As I said in the initial posting, which has to do with the keywords/tags-
At least tags generate more links to index in search engine if have different title and description. I don't know if it bad or good for site. Some SEO expert can guide in this matter.

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #9 on: May 30, 2013, 11:19:00 PM »
Yes its diffrent thing, but you create this mod you better know where and how to add WYSIWYG editor in this mode. Once i tried to change 4images for article but mod add WYSIWYG editor in user section not in admin section for add article etc. People who are not coder can not do this. A light WYSIWYG editor will be good enough
Things like that (added-n MODS to this MOD) can be added in the comments, not as a part of the MOD itself. This MOD is for the basic 4images. What I mean by this, for example, is I have also modified V@no's Comments MOD to work with the comments for the articles. But that isn't a part of this MOD's main features. The same would apply to WYSWYG editor.

At least tags generate more links to index in search engine if have different title and description. I don't know if it bad or good for site. Some SEO expert can guide in this matter.
Which is why I posted about some help in that regard LOL

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #10 on: June 01, 2013, 05:26:35 PM »
Very nice Mod!!

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #11 on: June 01, 2013, 10:29:31 PM »
Thanks!

Offline buuben

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #12 on: July 16, 2013, 02:31:03 AM »
Seems like it's not working with custom image fields...

See the attachment.


Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #13 on: August 09, 2013, 07:29:49 PM »
Looks like your DataBase doesn't have the i.image_town column/field, and that is NOT a part of this MOD.

Offline dsc_phi

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • MonSitePhotos
Re: W.I.P. - MOD- Articles and Article Categories
« Reply #14 on: July 09, 2014, 12:53:13 AM »
Bonjour à tous,

Je préfère vous l'écrire en français, car en anglais ce serait une catastrophe.
J'ai fait des corrections pour réussir à faire fonctionner ce système excellent d'article et catégorie.
Je n'ai pas trouvé l'astuce pour éviter les warnings cités plus haut par un autre internaute, donc j'ai créé un "root" bis sur la même sql. Il semblerait que tous les ajouts fait via includes/db_field_definitions.php ... provoquent ces warning, mais je n'ai pas la réponse.

J'ai modifié quelque chose qui pourra certainement aider certains parmi vous qui souhaiterai utiliser la réception des emails lors d'un post commentaire.

Je suis venu à cette correction, par hasard en comparant le code de detais.php, je recevais un mail même si c'est j'était l'auteur ou pas. Avec cette modif j'ai corrigé deux problèmes ... je ne suis pas programmeur, je lis beaucoup ce forum et c'est ainsi que j'ai fait évoluer mon site.
Le second problème, est que la balise {article_title} ne fonctionnait pas dans la mail warning, il y avait un espace à la place du nom de l'article. Avec cette modif, c'est aussi corrigé.

Je me suis appuyé sur une modif proposée dans ce forum à ce lien :
http://www.4homepages.de/forum/index.php?topic=2705.0

Voici donc ma modif :

Remplacer le code d'origine de save comment par celui ci :

//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error 0;
if (
$action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
  
$id intval($HTTP_POST_VARS[URL_ID]);
  
$sql "SELECT cat_id, article_allow_comments
          FROM "
.ARTICLE_TABLE."
          WHERE article_id = 
$id";
  
$row $site_db->query_firstrow($sql);

  if (
$row['article_allow_comments'] == || !check_permission("auth_postcomment"$row['cat_id']) || !$row) {
    
$msg $lang['comments_deactivated'];
  }
  else {
    
$user_name un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
    
$comment_text un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));

    
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";

    
// Flood Check
    
$sql "SELECT comment_ip, comment_date
            FROM "
.COMMENTS_ARTICLE_TABLE."
            WHERE article_id = 
$id
            ORDER BY comment_date DESC
            LIMIT 1"
;
    
$spam_row $site_db->query_firstrow($sql);
    
$spamtime $spam_row['comment_date'] + 180;

    if (
$session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN)  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['spamming'];
      
$error 1;
    }

    
$user_name_field get_user_table_field("""user_name");
    if (!empty(
$user_name_field)) {
      if (
$site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("""user_id")." <> '".$user_info['user_id']."'")) {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_exists'];
        
$error 1;
      }
    }
    if (
$user_name == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['name_required'];
      
$error 1;
    }
    if (
$comment_text == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['comment_required'];
      
$error 1;
    }

    if (
$captcha_enable_comments && !captcha_validate($captcha)) {
      
$msg .= (($msg != "") ? "<br />" "").$lang['captcha_required'];
      
$error 1;
    }

    if (!
$error)  {

       
$sql "INSERT INTO ".COMMENTS_ARTICLE_TABLE."
              (article_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
              VALUES
              (
$id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
      
$site_db->query($sql);
      
$commentid $site_db->get_insert_id();
      
update_comment_count($id$user_info['user_id']);
     
        
//-----------------------------------------------------
// Start Emailer for comments
//----------------------------------------------------- 
   
$recipient_name $article_row['user_name'];
   
$recipient_email $article_row['user_email'];
   
$article_url $script_url."/article.php?".URL_ARTICLE_ID."=".$id."";

   
$sql "SELECT user_com_mail FROM ".USERS_TABLE." WHERE ".get_user_table_field("""user_name")." = '".$recipient_name."'";
   
$result $site_db->query($sql);
   
$row $site_db->fetch_array($result);
   
$user_com_mail = ($row['user_com_mail']);

   if (
$article_row['user_id'] != $user_info['user_id'] && $user_com_mail == 1) {
   include(
ROOT_PATH.'includes/email.php');
    
$site_email = new Email(); 
    
$site_email->set_to($recipient_email); 
    
$site_email->set_from($config['site_email'], $config['site_name']); 
    
$site_email->set_subject($lang['comment_mail_image']); 
    
$site_email->register_vars(array( 
      
"user_name" => stripslashes($user_name), 
      
"recipient_name" => stripslashes($article_row['user_name']),
      
"article_title" => $article_row['article_title'], 
      
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $current_time), 
      
"site_name" => $config['site_name'],
      
"comment_text" =>(stripslashes($comment_text)),
      
"article_url" => $article_url,
      
"url_home" => $url_home,
          ));
    
$site_email->set_body("comment_email_article"$config['language_dir']); 
    
$site_email->send_email();
      }
    
$msg $lang['comment_success'];
    
$site_sess->set_session_var("msgdetails"$msg);
    
redirect(ROOT_PATH."article.php?".URL_article_ID."=".$article_id.((!empty($mode)) ? "&mode=".$mode "").(($page 1) ? "&page=".$page ""));
    }
  }
 unset(
$row);
 unset(
$spam_row);
}


Bravo et merci à l'auteur de cette modif, dommage qu'il n'y ait pas plus d'intéressés car elle est vraiment excellent.

Phi ...
www.monsitephotos.com

PS : Si vous visitez mon site et que vous ne voyez pas le copyright 4images, c'est parce que j'ai acheté une licence pour ce nom de domaine.
« Last Edit: July 10, 2014, 11:55:37 PM by dsc_phi »