本文整理汇总了PHP中app\models\Page::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::find方法的具体用法?PHP Page::find怎么用?PHP Page::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Page
的用法示例。
在下文中一共展示了Page::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSavePage
/**
* Saved edited page; called viea ajax
* @return String
*/
public function postSavePage()
{
$okay = true;
$page_id = $_REQUEST['page_id'];
$page_content = $_REQUEST['thedata'];
if ($page_id > 0) {
$page = Page::find($page_id);
} else {
$page = new Page();
$slugify = new Slugify();
$browser_title = $_REQUEST['browser_title'];
$page->browser_title = $browser_title;
$page->slug = $slugify->slugify($browser_title);
// verify that the slug is not already in the db
$results = Page::where('slug', $slugify->slugify($browser_title))->get();
foreach ($results as $result) {
$okay = false;
}
}
$page->page_content = $page_content;
if ($okay) {
$page->save();
echo "OK";
} else {
echo "Browser title is already in use";
}
}
示例2: actionIndex
public function actionIndex()
{
$request = Yii::$app->request;
$page_id = $request->get('page_id');
$search = $request->get('search');
$columns = Page::find()->where(['type' => 4])->all();
if ($search) {
$query = Photo::find()->where(['like', 'title', $search]);
$countQuery = clone $query;
$pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
$photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'post' => $post, 'columns' => $columns]);
}
if ($page_id) {
$query = Photo::find()->where(['page_id' => $page_id, 'parent_id' => 0]);
$countQuery = clone $query;
$pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
$photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
} else {
$query = Photo::find()->where(['parent_id' => 0])->andWhere(['>', 'page_id', 1]);
$countQuery = clone $query;
$pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
$photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
}
return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'photo' => $photo, 'columns' => $columns]);
}
示例3: destroy
public function destroy($id)
{
$page = Page::find($id);
//$page->delete();
Notification::success('The page was deleted.');
return Redirect::route('admin.pages.index');
}
示例4: run
public function run()
{
$menu = Menu::find()->where(['position' => 'bottom'])->one();
$p = explode(',', $menu->content);
$model = Page::find()->where(['id' => $p])->all();
return $this->render('links', ['pages' => $model]);
}
示例5: actionView
/**
* Displays a single Post model.
* @param integer $id
* @return mixed
*/
public function actionView($name)
{
$pages = Page::find()->all();
foreach ($pages as $key => $value) {
$menuItems[] = ['label' => $value->name, 'url' => ['page/view', 'name' => $value->name]];
}
return $this->render('view', ['model' => $this->findModel($name), 'pages' => $pages, 'menuItems' => $menuItems]);
}
示例6: actionSlug
public function actionSlug($slug)
{
$model = Page::find()->where(['slug' => $slug])->one();
if (!is_null($model)) {
return $this->render('view', ['model' => $model]);
} else {
return $this->redirect('index');
}
}
示例7: search
/**
* Creates data provider instance with search query applied
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Page::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
$query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]);
return $dataProvider;
}
示例8: search
public function search($params)
{
$query = Page::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]);
return $dataProvider;
}
示例9: __construct
public function __construct()
{
$this->setting = Settings::getSetting();
View::share('listNewPd', $this->_getNewProduct());
View::share('listNewsTop', $this->_getNewsTop());
View::share('Category', $this->getCategoryShowInIndex());
View::share('menu_provider', $this->getProviderShowInIndex());
View::share('setting', $this->setting);
View::share('guideDes', Page::find(4));
View::share('title', "");
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Page::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'image_id' => $this->image_id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'lang', $this->lang]);
return $dataProvider;
}
示例11: actionView
public function actionView($alias)
{
$this->layout = 'main';
$model = Page::find()->where(['alias' => $alias, 'status' => Page::STATUS_PUBLISHED, 'lang' => Yii::$app->language])->one();
if (!$model) {
$model = Page::find()->where(['alias' => $alias, 'status' => Page::STATUS_PUBLISHED, 'lang' => Yii::$app->sourceLanguage])->one();
if (!$model) {
throw new NotFoundHttpException(Yii::t('page', 'Page not found'));
}
}
return $this->render('view', ['model' => $model]);
}
示例12: actionIndex
/**
* Action that displays pages list
* @return string
*/
public function actionIndex()
{
$pages = Page::find()->orderBy(['created_at' => SORT_DESC]);
$count = Yii::$app->cache->lazy(function () use($pages) {
return $pages->count();
}, 'PagesCount', 86400, Page::commonTag());
$pagination = new Pagination(['totalCount' => $count]);
$pages = Yii::$app->cache->lazy(function () use($pages, $pagination) {
return $pages->offset($pagination->offset)->limit($pagination->limit)->all();
}, "Pages:{$pagination->offset}:{$pagination->limit}", 86400, Page::commonTag());
return $this->render('index', ['pages' => $pages, 'pagination' => $pagination]);
}
示例13: actionUpdate
/**
* Updates an existing Menu model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$pages = Page::find()->all();
if ($model->load(Yii::$app->request->post())) {
$menu->content = implode(',', $menu->content);
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
} else {
return $this->render('update', ['model' => $model, 'pages' => $pages]);
}
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Page::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'live' => $this->live, 'date_updated' => $this->date_updated, 'date_published' => $this->date_published]);
$query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
return $dataProvider;
}
示例15: run
public function run()
{
$menu = Menu::find()->where(['position' => 'top'])->one();
$p = explode(",", $menu->content);
$pages = Page::find()->where(['id' => $p])->all();
if (strpos(\Yii::$app->request->url, "view-post")) {
$post = Post::findOne(\Yii::$app->request->get('id'));
$current_page = $post->page;
} else {
$slug = \Yii::$app->request->get('slug');
$current_page = Page::find()->where(['slug' => $slug])->one();
}
return $this->render('nav', ['pages' => $pages, 'current_page' => $current_page]);
}