New Article: Set Default Title = Category Name

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
phalancs
Posts: 793
Joined: Thu 19. Feb 2004, 05:09
Location: Germany

New Article: Set Default Title = Category Name

Post 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;

}
2008
Post Reply