Page 1 of 1

New Article: Set Default Title = Category Name

Posted: Wed 2. Nov 2011, 17:12
by phalancs
Its always anoying to create a new article an fill in all those fields. I think it might be handy if there is one more default value.
Usually I have one article per category and I think this is very common. The article title then equals the category name. So why not have this as default.

If you want it to be like that open this file:

/include/inc_tmpl/article.editsummary.tmpl.php

FIND THIS LINE

Code: Select all

$template_default['article']['imagelist_default_height'] = isset($template_default['article']['imagelist_default_height']) ? $template_default['article']['imagelist_default_height'] : '' ;
ADD THIS AFTER IT, but before ?>

Code: Select all

//phalancs: load default article name if article title is empty (use category name):
if ($article["article_title"] == '') {

      $sql = "SELECT acat_name FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id=".$article['article_catid']." LIMIT 1;";
      if($result = mysql_query($sql) or die ("error" . mysql_error())) {
     		while($row = mysql_fetch_assoc($result)) {
  			$cat_name = $row['acat_name'];
    		}
      }      

$article["article_title"] = $cat_name;

}