Home php教程 php手册 openPNE常用方法分享

openPNE常用方法分享

Jun 13, 2016 pm 12:03 PM
array include php code share copy Commonly used method

复制代码 代码如下:


'asdfgasgsad'));?>这句话意思是包含'_sidemenu.php'并往其页面传一系列参数,'_sidemenu.php'页即可直接使用$form变量中的值
op_include_box('vote_question_create_box','asdfasdf',array('title'=>'创建问题','moreInfo'=>array('创建问题',link_to('创建问题2','@my_index'))));
?>
op_include_box('vote_question_create_box',get_slot('pager'),array('title'=>'创建问题','moreInfo'=>array('创建问题',link_to('创建问题2','@my_index'))));
?>
'vote_question_create_box'只是一个标记,'asdfasdf'或 get_slot('pager')则是要输出到页面上标题下的信息(这个方法里要包含slot只能用get_slot()不能用include_slot(),
而在页面中要包含slot则必须使用include_slot())
第三个数组参数中的键值名称title是固定的,是该段'vote_question_create_box'显示的标题,后面的'moreInfo'键名也是固定键值对应的数组则是罗列显示的内容列表

设定一个slot段落


包含指定的slot段落,设定的slot段落必须通过包含才能在页面上显示

op_include_form('vote_question_from',$form,array('title'=>'编辑问题','url'=>url_for('@vote_update?id='.$form->getObject()->getId()),));
?>包含一个表单对象,'vote_question_from'为标识名,$form为对应动作传来的表单对象,第三个数组参数title键值也url键值是固定的,分别对应显示的标题名和表单提交路径
对应动作内容为
public function executeEdit(sfWebRequest $request){
$object = $this->getRoute()->getObject();
//如果不是作者屏幕上显示404
$this->forward404Unless($this->getUser()->getMemberId() == $object->getMemberId());//$object->getMemberId()为传递过来的id值对应的那条记录的member_id字段值
$this->form = new VoteQuestionForm($object);
//访问此动作路径http://localhost/openpne/web/vote/edit/1
}
?>

用于分页时前后翻页的超链接
$pager来自动作里的 $this->pager = Doctrine::getTable('VoteQuestion')->getListPager($request->getParameter('page'));
PluginVoteQuestionTable类getListPager()方法里的内容↓
class PluginVoteQuestionTable extends Doctrine_Table
{
public function getListPager($page = 1,$size = 20)
{
$query = $this->createQuery()->orderBy('updated_at DESC');
$pager = new sfDoctrinePager('VoteQuestion',$size);//创建一个某表的分页对象,并传一个每页显示多少记录值
$pager->setQuery($query);//传一个查询语句对象
$pager->setPage($page);//设返回显示的页数
$pager->init();
return $pager;
}
}
?>
对应前台页面对分页结果集的沥遍
getResults() as $item): //利用openPNE分页机制获取指定分页结果集并沥遍每一条记录?>


getUpdatedAt(),'f') //'f'代表一种显示格式?>

getTitle(),count($item->getVoteAnswers())),'@vote_show?id='.$item->getId()) ?>




getId()) ?>相当于sdsfg
表名是驼峰模式在数据库里以下划线表示,字段名也是如此

链接的
就算不用方法也可以直接在action="此可直接写web/后的====模块名/动作名====或路由中设定好的web后的路径"

动作里的
$this->tasksObject = $this->getRoute()->getObject();
$this->getRoute()->getObject();//获取传过来的id参数值对应的表中的那条信息对象可通过get+字段名()获取字段值,如在页面中$tasksObject-getId();
至于如何确定获取的是哪个表则是通过路由类设置该动作路由时确定的,如下例确定的是vote_question表

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')
),
);
}
}
?>
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles