Comments into News

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
kishman155
Translator
Translator
Posts: 169
Joined: Sat Mar 12, 2005 12:30 pm

Re: Comments into News

Post by kishman155 »

Taken from Produkts


new field in newsdatabase or new table so it could be more comments to one news

Code: Select all

comment X,
the button in the news defaultadmin

Code: Select all

echo "<td>".$this->CreateLink($id, 'News', $returnid, 'Comment', array("action"=>"comment","newsid"=>$row["news_id"]))."</td>\n";
the edit comment case

Code: Select all

case "comment":
			$newsid = (isset($_GET[$id."newsid"])?$_GET[$id."newsid"]:"").(isset($_POST[$id."newsid"])?$_POST[$id."newsid"]:"");
				$query = "SELECT * FROM ".cms_db_prefix()."module_news WHERE news_id = ".$newsid."";
				$dbresult = $db->Execute($query);
				if ($dbresult && $dbresult->RowCount() > 0)
				{
					$row = $dbresult->FetchRow();
					$comment = $row["comment"];
					$this->commentForm($id, 'savecomment', '', $comment, $newsid);
				}
				break;
save comment
case "savecomment":

if (isset($params['cancelsubmit']))
{
$this->Redirect($id, 'defaultadmin');
}

$newsid = (isset($params['newsid '])?$params['newsid ']:"");
$comment = (isset($params['comment'])?$params['comment']:"");

$query = "UPDATE ".cms_db_prefix()."module_news SET comment = ?";
$params = array($comment);
$query .= " WHERE news_id = ?";
array_push($params, $newsid);
$dbresult = $db->Execute($query, $params);
$this->Audit($id, 'produkts', 'audit');
$this->Redirect($id, 'defaultadmin');
return;
break;
the form

Code: Select all

function commentForm($id, $moduleaction, $error='', $comment='', $newsid = '')
	{
      $db = $this->cms->db;
      echo "<div class="adminform"";?>
      <table width="100%" border="0">
      <?php
        echo $this->CreateFormStart($id, $moduleaction);?>
<tr>
			<td style="vertical-align:top;">Info:</td>
			<td><?php echo $this->CreateTextarea(true, $id, $comment, 'comment', 'syntaxHighlight', 'comment') ?>
			</td>
			</tr></table>
			<?php echo $this->CreateInputHidden($id, 'newsid', $newsid);?>
			<?php echo $this->CreateInputSubmit($id, 'submit', 'Submit') ?>
			  <?php echo $this->CreateInputSubmit($id, 'cancelsubmit', 'Cancel') ?>
		<?php echo $this->CreateFormEnd();
		echo "</div>";
		}
mfg
Kris

ps taken from produkts
infusion

Re: Comments into News

Post by infusion »

hi patricia,

If you manage to do it, could you kindly post a step by step process of achieving it coz i don't quite understand all the code poted on top there. Thanks a lot
Post Reply

Return to “Modules/Add-Ons”