Monday, February 18, 2008

symfony askeet tutorial

day 12

add

<?php echo link_to('Forgot your password?', '@user_require_password') ?>

to the login form, under wrong password div

at the end of the tutorial, you'll have the function not exist error:
Call to undefined function form_error()

you just need add <?php use_helper('Validation'); ?> to top of
user/passwordRequestSuccess.php

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>

symfony askeet tutorial

finally get the symfony ajax installation correctly.

this should be for day1 but i found the problem on day8 when i need ajax.

bascially 2 points: wamp has 2 php.ini files AND the pear path is point to c:\php5\pear\

more reference to read

http://www.symfony-project.org/forum/index.php?t=msg&&th=5339&goto=22910
http://trac.symfony-project.com/wiki/SymfonyOnWAMP

also, a chinese reference:
http://www.watir.cn/?p=18

Friday, February 15, 2008

symfony askeet tutorial

day 7 problem solved, seems i had problem in previous day 5. i did all from day 2-7, it's all fine.

got problem in day 8, after add the ajax, got fatal error.
solution is found in forum at:  http://www.symfony-project.org/forum/index.php/m/22875/
pay attention to the last reply, that's the solution i take. also found a bug report regarding to the fatal error, seems it's about the PK

--
Kindest Regards,

Zhen Sun

Thursday, February 14, 2008

symfony askeet tutorial

on day7, got problem to show the user profile. need sort out.

when 'we can also link to a user profile from a question', solve 'Don't forget to declare the use of the Date helper in _list.php.' by add <?php use_helper('Date', 'Global') ?> on top  of _list.php, I guess add <?php use_helper('Date') ?> would work too.

when add sidebar

on the view.yml

default:
components:
sidebar: [sidebar, default]


actually just need

components:
sidebar: [sidebar, default]

otherwise there's 2 default keywords in the yml file and get a non-css and non-sidebar page


the user profile problem remains, even after checked the askeet SVN repository. will need a further investigation later.

Wednesday, February 13, 2008

symfony askeet tutorial

this is the first day on the tutorial.

in the tutorial, day4 takes sometime to learn, a lot of reference to read.

day5's last piece is not correct. need rename the downloaded _question_list.php to _list.php, also you'd better copy the content from previous listSuccess.php and get rid of the <h1></h1> part to the _list.php

actually, just create the _list.php, then copy the content from listSuccess.php, delete the line of <h1></h1>

then change the listSuccess.php content to
<h1>popular questions</h1>

<?php echo include_partial('list', array('question_pager' => $question_pager)) ?>

day6,

when add the secureity.yml
all:
is_secure: on
credentials: subscriber

make sure you read the notes, and change on to off

public
function handleErrorLogin()
{
return sfView::SUCCESS;
}

don't forget to add this method to user actions.classe.php to handle the error.

Tuesday, February 12, 2008

learning symfony

follow the tutorial, build imagegallery db, and modify config/database.yml and propel.ini.

when run the last step symfony propel-generate-crud backend images Image

got error Unable to scafford unexistant model 'Image'

look like i didn't setup the Image model. so i leave this tutorial alone and go back to do the symfony site official tutorail on http://www.symfony-project.org/tutorial/1_0/my-first-project

called

My first symfony project

first problem when create the model, need enable extension=php_xsl.dll of PHP

still have the same error, but doesn't matter. seems the model is still created and

http://localhost/sf_sandbox/web/frontend_dev.php/pos
http://localhost/sf_sandbox/web/frontend_dev.php/comment

work fine.

when u add validation onto the comment form, the instruction is

Now to finish, open again the modules/comment/templates/editSuccess.php template and insert at the top:

actually, it means insert to the top of the table, right after <tbody>


on the change the URL aspect part, there's a little problem of modifying the template, tutorial is not totally correct, you'd better have a look the final result image and finger out how to modify the template. the part modify the table cells.

this example is completed finally, but it is far from master it.

learning symfony

i got the sandbox works first, that's no trick there. but finally i decided to use pear installation.

so 1st step is to install pear on my wamp, you need add php to the windows environment path variable  ie:c:\wamp\bin\php\php5.2.5\
then run go-pear.bat to install pear
then install symfony  pear package  follow the instruction on http://www.symfony-project.org/book/1_1/03-Running-Symfony

i did the test initial project on that page, now working on a tutorial on http://www.odeweb.com/2008/01/25/symfony-crud-a-how-to/