Monday, February 18, 2008

symfony askeet tutorial

on day8,

add <?php use_helper('Javascript') ?> right be4 </header>


then add

<div id="login" style="display: none">
<h2>Please sign-in first</h2>

<?php echo link_to_function('cancel', visual_effect('blind_up',
'login', array('duration' => 0.5))) ?>

<?php echo form_tag('user/login', 'id=loginform') ?>
nickname: <?php echo input_tag('nickname') ?><br />
password: <?php echo input_password_tag('password') ?><br />
<?php echo input_hidden_tag('referer', $sf_params->get('referer')
? $sf_params->get('referer') : $sf_request->getUri()) ?>
<?php echo submit_tag('login') ?>
</form>
</div>

right be4
<div id="content">

"Have the form appear when a non-authenticated user clicks an interested link"

askeet/lib/helper/UserHelper.php

should be

askeet/apps/frontend/lib/helper/UserHelper.php

on day9, "Modify the templates"

in showSuccess.php
change <?php echo $question->getBody() ?>
to <?php echo $question->getHtmlBody() ?>


in _list.php
change <?php echo truncate_text($question->getBody(), 200) ?>
to <?php echo truncate_text(strip_tags($question->getHtmlBody()), 200) ?>


day10

isInterestedIn() is created in askeet\lib\model\User.php

the refactoring is, in user/action

change

public function executeInterested()
{
$this->question =
QuestionPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($this->question);

$user = $this->getUser()->getSubscriber();

$interest = new Interest();
$interest->setQuestion($this->question);
$interest->setUser($user);
$interest->save();
}

to

public function executeInterested()
{
$this->question =
QuestionPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($this->question);

$this->getUser()->getSubscriber()->isInterestedIn($this->question);
}


another refactoring is, in UserHelper.php
change
return link_to_function('interested?', visual_effect('blind_down',
'login', array('duration' => 0.5)));
to
return link_to_login('interested?');

update modules/sidebar/templates/defaultSuccess.php
to
<?php use_helper('User') ?>

<?php echo link_to_login('ask a new question', '@add_question') ?>

<ul>
<li><?php echo link_to('popular questions', '@popular_questions') ?>
<li><?php echo link_to('latest questions', '@recent_questions') ?></li>
<li><?php echo link_to('latest answers', '@recent_answers') ?></li>
</ul>

1 comment:

Anonymous said...

on day 9,change the templates for hide all ids.

Replace <?php echo link_to($question->getUser(), 'user/show?id='.$question->getUserId()) ?$gt; by <?php echo link_to($question->getUser(), 'user/show?nickname="'.$question->getUser()->getNickname())" ?> in the question/showSuccess.php,question/_list.php templates.That's successful.

The same kind of modification goes for the answer/_answer.php template.It will display an error when you click the link latest answers in sidebar.

modify this line : 'user/show?nickname="'.$question->getUser()->getNickname())
replace" $question by $answer,that will display successfully.