Openpne common ways to share _php tutorials

Source: Internet
Author: User
Tags php foreach
Copy CodeThe code is as follows:
' Asdfgasgsad '); > This sentence means to include ' _sidemenu.php ' and pass a series of parameters to its page, ' _sidemenu.php ' page can directly use the value in the $form variable
Op_include_box (' Vote_question_create_box ', ' ASDFASDF', Array (' title ' = ' Create problem ', ' moreinfo ' =>array (' Create Problem ', link_to (' Create question 2 ', ' @my_index ')));
?>
Op_include_box (' Vote_question_create_box ', get_slot (' pager '), Array (' title ' = ' Create problem ', ' moreinfo ' =>array (' Create question ', link_to (' Create question 2 ', ' @my_index ')));
?>
' Vote_question_create_box ' is just a sign, ' ASDFASDF' or get_slot (' pager ') is to output to the page under the title of the information (this method to include slots can only use Get_slot () can not use Include_slot (),
To include slots in the page, you must use Include_slot ())
The name of the key value in the third array parameter is fixed, the title of the Section ' Vote_question_create_box ' is displayed, and the following ' MoreInfo ' key name is also an array of fixed key values that lists the contents of the display.

Set a slot paragraph


Contains the specified slot paragraph, which must be included to display on the page

Op_include_form (' Vote_question_from ', $form, Array (' title ' = ' edit problem ', ' url ' =>url_for (' @vote_update? id= '). Form->getobject ()->getid ()));
?> contains a Form object, ' Vote_question_from ' is the identity name, $form the form object that the corresponding action came from, the third array parameter title key value is also fixed, corresponding to the title name of the display and the form submission path
The corresponding action content is
Public Function Executeedit (sfwebrequest $request) {
$object = $this->getroute ()->getobject ();
If not displayed on the author screen 404
$this->forward404unless ($this->getuser ()->getmemberid () = = $object->getmemberid ());//$object Getmemberid () The MEMBER_ID field value of the record that corresponds to the ID value passed in.
$this->form = new Votequestionform ($object);
Access this action path HTTP://LOCALHOST/OPENPNE/WEB/VOTE/EDIT/1
}
?>

Hyperlinks for paging back and forth
$pager from the action $this->pager = doctrine::gettable (' votequestion ')->getlistpager ($request->getparameter (' Page '));
Content in the Pluginvotequestiontable class Getlistpager () method ↓
Class Pluginvotequestiontable extends Doctrine_table
{
Public Function Getlistpager ($page = 1, $size = 20)
{
$query = $this->createquery ()->orderby (' Updated_at DESC ');
$pager = new Sfdoctrinepager (' Votequestion ', $size);//Create a paging object for a table and pass a number of record values per page
$pager->setquery ($query);//Pass a query statement object
$pager->setpage ($page);//Set returns the number of pages displayed
$pager->init ();
return $pager;
}
}
?>
To drain the pagination result set for the foreground page
GetResults () as $item)://Use the OPENPNE paging mechanism to get the specified paged result set and to drain each record?>

Getupdatedat (), ' f ')//' F ' represents a display format?>

GetTitle (), Count ($item->getvoteanswers ())), ' @vote_show? id= '. $item->getid ())?>




GetId ())?> equivalent to SDSFG
The table name is Hump mode, which is underlined in the database, so is the field name.

Linked to
Even if you do not have a method can be directly in the action= "This can be directly written web/after the module name/action name = = or the route set in the web after the path"

In action.
$this->tasksobject = $this->getroute ()->getobject ();
$this->getroute ()->getobject (); Gets the value of the field in the table corresponding to the ID parameter value passed in by get+ field name (), such as $tasksobject-getid () in the page;
As to how to determine which table to obtain is determined by the routing class when the action route is set, the following example determines the Vote_question table
Cases
Class Opvotepluginfrontendroutecollection extends Sfroutecollection
{
Public function __construct (array $options)
{
Parent::__construct ($options);
$this->routes = Array (
' Vote_edit ' = new Sfdoctrineroute (
'/vote/edit/:id ',
Array (' module ' = ' vote ', ' action ' = ' edit '),
Array (' id ' = ' \d+ ', ' sf_method ' = = Array (' get ')),
Array (' model ' = ' votequestion ', ' type ' = ' object ')
),
);
}
}
?>

http://www.bkjia.com/PHPjc/324727.html www.bkjia.com true http://www.bkjia.com/PHPjc/324727.html techarticle Copy the code as follows: Php include_partial (' Sidemenu ', Array (' form ' = ' asdfgasgsad '));? This sentence means to include ' _sidemenu.php ' and pass a series of parameters to its page, ' _sidemenu.php ' page ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.