Homepage of www.easymagazine.net | Wem site map of www.easymagazine.net | Email the author of www.easymagazine.net

 

Designing an comments.php template script for Easy Magazine

The comments.php script contains a list of comments related to a gived article and a form to submit new comments. All the logic to submit new comments is ready to be used. All you need to do is just create the form.

The comments related to an article

Accessible data:

  • $this->article:
  • the article gived (Article)
  • $this->number:
  • contains last number published (Number)
  • $this->numbers:
  • array with the last 10 numbers published (array Number(s))
  • $this->categories:
  • array containing all categories of the magazine (array Category)
  • $this->pages:
  • array containing all pages published (array Page)
  • $this->metadescritpion:
  • string containing the metadescription of the page (String)
  • $this->metakeywords:
  • string containing the metadescription of the page (String)
  • $this->title:
  • string created to fill the title tag (String)

An example of code:

<h2>
<?= $this->article->getTitle(); ?>
</h2>

<div class="date"><?= $this->article->getCreatedFormatted() ?> by <?
foreach ($this->article->users() as $user) {
echo $user->getName().' ';
}
?>
</div>

<div class="entry">
<?= $this->article->getSummary() ?>
</div>
<h3>Comments</h3>
<?
if (isset($this->advice)) {
echo '<b>'.$this->advice.'</b>';
}
?>
<? foreach($this->article->commentsPublished() as $comment) { ?>
<div class="date"><?= $comment->getCreatedFormatted() ?> by
<?= $comment->getSignature() ?>
</div>
<div class="entry">
<?= $comment->getTitle() ?>
<?= $comment->getBody() ?>
</div>
<? } ?>
<? if ($this->article->getCommentsallowed() && $this->article->number()->getCommentsallowed()): ?>
<p> <form name="newcomment" method="post" action="<?= URIMaker::comment($this->article) ?>">
Title
<input type="text" name="Title" value=""/>
Body
<textarea name="Body" rows="4" cols="40">
Signature
<input type="text" name="Signature" value=""/>

<img src="<?= URIMaker::fromBasePath('lib/securimage/securimage_show.php?sid='.md5(uniqid(time())))?>">
<input type="text" name="code" />

<input type="submit" value="Ok" name="Ok" />
</form>
</p>
<? endif; ?>

The fields name (Title, Body, Signature) is a constrain.

 


Copyright © 2009, 2010, 2011 Fabio Mattei, designed by zuudesign.sk