protected function findModel($id) { if (($model = Seo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function postPage(Request $request) { //echo '<pre>',print_r($request->all()),'</pre>'; $chk = Content::where('content_type', $request->input('content_type'))->first(); $content = $chk ? $chk : new Content(); $content->content_subject = $request->input('content_subject'); $content->content_description = $request->input('seo_description'); $content->content_detail = $request->input('content_detail'); $content->content_type = $request->input('content_type'); $content->save(); $cseo = Seo::where('ref_id', $content->id)->where('seo_type', $content->content_type)->first(); $seo = $cseo ? $cseo : new Seo(); $seo->title = $request->input('seo_title'); $seo->keywords = $request->input('seo_keywords'); $seo->description = $request->input('seo_description'); $seo->ref_id = $content->id; $seo->seo_type = $content->content_type; $seo->save(); return redirect()->back(); }
<div class="top__logo"> <a href="/"><img src="<?php echo Url::to('/web/images/logo.png'); ?> " alt="#"></a> </div> <!--.top__logo--> <?php if (Yii::$app->user->isGuest) { ?> <div class="top__social"> <?php $seo = Seo::find()->where(['id' => 1])->one(); ?> <ul> <li class="fb"><a href="javascript:void(0);" onclick="Share.facebook('<?php echo 'http://' . Yii::$app->request->getServerName(); ?> ', '<?php echo $this->title; ?> ', '<?php echo 'http://' . Yii::$app->request->getServerName() . '/web/upload/default/' . $seo->images; ?> ', '<?php echo $seo->title; ?>
use yii\helpers\VarDumper; use yii\web\JqueryAsset; use yii\widgets\ActiveForm; use yii\captcha\Captcha; use app\models\LoginForm; use app\models\SignupForm; use app\models\User; use app\models\Seo; use yii\base\InvalidParamException; use yii\web\BadRequestHttpException; use yii\web\Session; use yii\web\Response; use app\components\AlertWidget; use nodge\eauth\Widget; use app\models\PasswordResetRequestForm; $this->title = Seo::find()->where(['id' => 1])->one()->title; ?> <div class="vam block__hide " > <div class="vam__in animate"> <div class="main_page "> <div class="txt1"> <h2>Чи голосуєш<br>ти на виборах?</h2> <p>Проект «Чому?» — всеукраїнське соціологічне дослідження, метою якого є <br> звернути увагу суспільства та влади на мотивацію українців під час голосувань на виборах. <br>Організатор опитування, ГО "ВО Успішна країна”, гарантує повну конфіденційність відповідей.</p> </div> <div class="main_page__switch"> <div class="main_page__switch-btn main_page__switch-btnleft main_page__switch-btn--active" onclick="OpenYes(); return false;">Так, я голосую</div>
public function getMetaTagsDefault($false = null) { $seo = Seo::find()->where(['id' => 1])->one(); if ($false !== false) { \Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => isset($seo) && $seo !== null ? $seo->keywords : '']); \Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => isset($seo) && $seo !== null ? $seo->keywords : '']); \Yii::$app->view->registerMetaTag(['property' => 'og:url', 'content' => 'http://' . Yii::$app->request->getServerName()]); \Yii::$app->view->registerMetaTag(['property' => 'og:title', 'content' => $seo->title]); \Yii::$app->view->registerMetaTag(['property' => 'og:description', 'content' => $seo->description]); \Yii::$app->view->registerMetaTag(['property' => 'og:image', 'content' => 'http://' . Yii::$app->request->getServerName() . '/web/upload/default/' . $seo->images]); \Yii::$app->view->registerMetaTag(['property' => 'og:site_name', 'content' => $seo->title]); } return true; }
/** * Store a newly created resource in storage. * * @return Response */ public function store($postTypeId, PostRequest $request) { //if(!$this->authUser->can('create-edit-news') && !$this->authUser->is('superadmin')) // App::abort(403, 'Access denied'); $input = $request->all(); //create the post $post = $this->postRepos->create($input); //upload the image via service if (isset($input['image'])) { $this->postService->uploadImage($post, $input['image']); } //add seo polymorphic model $seo = new Seo(); $seo->updateFromInput($input); $post->seo()->save($seo); Flash::success('Post was created successfully.'); return Redirect::route('admin.posts.list', [$postTypeId]); }