-
Hiển thị 1-25 của 53 tin nhắn. Mạch tin nhắnĐã gửi cách đây 5200 ngàyĐã gửi cách đây 5200 ngàyĐã gửi cách đây 5445 ngàyĐã gửi cách đây 5448 ngàyĐã gửi cách đây 5448 ngàyĐã gửi cách đây 5449 ngàyĐã gửi cách đây 5451 ngàyĐã gửi cách đây 5451 ngàyĐã gửi cách đây 5451 ngàyĐã gửi cách đây 5458 ngàyĐã gửi cách đây 5458 ngàyĐã gửi cách đây 5458 ngàyĐã gửi cách đây 5459 ngàyĐã gửi cách đây 5460 ngàyĐã gửi cách đây 5460 ngàyĐã gửi cách đây 5460 ngàyĐã gửi cách đây 5460 ngàyĐã gửi cách đây 5460 ngàyĐã gửi cách đây 5464 ngày
a. Create the user/login action In the user/actions/action.class.php file (under the new askeet/apps/frontend/modules/ directory), add the following login action: public function executeLogin() {
$this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer()); return sfView::SUCCESS;
} The return sfView::SUCCESS passes the result of the action to the loginSuccess.php template. This statement is implied in actions that don't contain a return statement, that's why the default template of an action is called actionnameSuccess.php.
Đã gửi cách đây 5464 ngàyChappter 05: Form and Pager 1. Login Form Give access to a login form from every page of the application. Open the global layout askeet/apps/frontend/templates/layout.php and add in the following line before the link to about:
- <?php echo link_to('sign in', 'user/login') ?></li> we will just ask symfony to create the module skeleton, and we will write the code ourselves. $ symfony init-module frontend user
Đã gửi cách đây 5465 ngàyc. Secure the updating request with a transaction save() method is a good opportunity to illustrate the implementation of transactions in symfony. Replace the code by:
d. Change the template the ->getInterestedUsers() method of the Question object works properly, it is time to simplify the _interested_user.php fragment by replacing: <?php echo count($question->getInterests()) ?> By <?php echo $question->getInterestedUsers() ?> e. Test the validity of the modification Run again the data import batch: $ cd /home/sfprojects/askeet/batch $ php load_data.php When creating the records of the Interest table, the sfPropelData object will use the overridden save() method and should properly update the related User records. Check it by requesting the home page and the detail of the first question: http://askeet/frontend_dev.php/ http://askeet/frontend_dev.php/question/show/id/XX f. 5.
Đã gửi cách đây 5465 ngàyb. Modify the Save() method of the Interest object Open the askeet/lib/model/Interest.php file and write in the following method: public function save($con = null) {
$ret = parent::save($con); // update interested_users in question table $question = $this->getQuestion(); $interested_users = $question->getInterestedUsers(); $question->setInterestedUsers($interested_users 1); $question->save($con); return $ret;
}The new save() method gets the question related to the current interest, and increments its interested_users field. Then, it does the usual save(), but because a $this->save(); would end up in an infinite loop, it uses the class method parent::save() instead.
Đã gửi cách đây 5465 ngày4. Modify the question Part II The $question->getInterests() call of the new fragment does a request to the database and returns an array of objects of class Interest. This is a heavy request for just a number of interested persons, and it might load the database too much. Remember that this call is also done in the listSuccess.php template, but this time in a loop, for each question of the list. It would be a good idea to optimize it. One good solution is to add a column to the Question table called interested_users, and to update this column each time an interest about the question is created. a. Add a field to the User object model Modify the askeet/config/schema.xml data model by adding to the ask_question table: <column name="interested_users" type="integer" default="0" /> Then rebuild the model: $ symfony propel-build-model We also need to update the actual database. To avoid writing some SQL statement, We should rebuild SQL schema and reload test data: $ symfony propel-build-sql $ mysql -u youruser -p askeet < data/sql/lib.model.schema.sql $ php batch/load_data.php Note: There is more than way to do it. Instead of rebuilding the database, you can add the new column to the MySQL table by hand: $ mysql -u youruser -p askeet -e "alter table ask_question add interested_users int default '0'"
Đã gửi cách đây 5465 ngày3. Don’t Repeat yourself One of the good principles of agile development is to avoid duplicating code.We probably noticed some duplicated code between the listSuccess.php template and the showSuccess.php template
<div class="interested_mark" id="mark_<?php echo $question->getId() ?>"> <?php echo count($question->getInterests()) ?>
</div> Create an _interested_user.php file in the askeet/apps/frontend/modules/question/templates/ directory with the following code: <div class="interested_mark" id="mark_<?php echo $question->getId() ?>">
<?php echo count($question->getInterests()) ?>
</div> Then, replace the original code in both templates (listSuccess.php and showSuccess.php) with:
<?php include_partial('interested_user', array('question' => $question)) ?>
tác giả
Tìm thêm với Google.com :
NHÀ TÀI TRỢ