Почему не открывается страница?
- Dominus
- Сообщения: 892
- Зарегистрирован: 2013.03.14, 21:27
- Откуда: Россия, Иваново
- Контактная информация:
Re: Почему не открывается страница?
В большинстве случаев, ошибка пользователей, я проанализирую информацию и дам ответ
Не спорь с дураком, иначе окружающие не правильно поймут кто из вас дурак!
- Dominus
- Сообщения: 892
- Зарегистрирован: 2013.03.14, 21:27
- Откуда: Россия, Иваново
- Контактная информация:
Re: Почему не открывается страница?
Эмм.. Почему закомментирован urlManager?
Скорее всего тут и кроется проблема)
Скорее всего тут и кроется проблема)
Не спорь с дураком, иначе окружающие не правильно поймут кто из вас дурак!
- Dominus
- Сообщения: 892
- Зарегистрирован: 2013.03.14, 21:27
- Откуда: Россия, Иваново
- Контактная информация:
Re: Почему не открывается страница?
Как мне смоделировать вашу ситуацию? Пока не понятно)
Не спорь с дураком, иначе окружающие не правильно поймут кто из вас дурак!
Re: Почему не открывается страница?
Если он раскомментирует urlManager, то можно пробовать открывать через меню
Код: Выделить всё
['label' => 'Cart', 'url' => ['cart']]
Код: Выделить всё
'<action>' => 'site/<action>',
Re: Почему не открывается страница?
права на чтение есть?
Re: Почему не открывается страница?
Всё работает. Вот скриншоты куда и что добавляется.
Скришот проекта https://prnt.sc/t89o3y
Прописать не забываем в CartController
Url страницы выходит такой mysite/cart/index
Вот сама вьюха https://prnt.sc/t89pl5
Скришот проекта https://prnt.sc/t89o3y
Прописать не забываем в CartController
Код: Выделить всё
public function actionIndex()
{
return $this->render('index',[
]);
}
Вот сама вьюха https://prnt.sc/t89pl5
Re: Почему не открывается страница?
И все js скрипты, которые работают с этим представлением через ajax тоже не работают(
Re: Почему не открывается страница?
Смотрите.
У меня не открывается вьюха, которую использует контроллер карт. Вернее она окрывается на ОпенСервере, но после переноса на хостинг - нет. И скрипты, которые отлично работают на Локальном сервере, на хосте не работают от слова совсем.
Вот контроллер cart:
Код: Выделить всё
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;
use app\models\Products;
use app\models\Category;
use yii\data\Pagination;
use app\models\SignupForm;
use app\models\User;
use app\models\Gallery;
use app\models\Orders;
use app\models\OrderForm;
class SiteController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post', 'get'],
],
],
];
}
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
$product_model = Products::find()->orderBy(['`id`' => SORT_DESC])->limit(4)->asArray()->all();
$gallery_model = Gallery::find()->orderBy(['`id`' => SORT_DESC])->limit(4)->asArray()->all();
return $this->render('index', compact('product_model', 'gallery_model'));
}
public function actionSignup() {
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new SignupForm;
if($model->load(\Yii::$app->request->post()) && $model->validate()){
$user = new User();
$user->username = $model->username;
$user->email = $model->email;
$user->password = Yii::$app->security->generatePasswordHash($model->password);
if($user->save()){
Yii::$app->user->login($user);
return $this->goHome();
}
}
return $this->render('signup', compact('model'));
}
/**
* Login action.
*
* @return Response|string
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
$model->password = '';
return $this->render('login', [
'model' => $model,
]);
}
/**
* Logout action.
*
* @return Response
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
/**
* Displays contact page.
*
* @return Response|string
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
}
return $this->render('contact', [
'model' => $model,
]);
}
/**
* Displays about page.
*
* @return string
*/
public function actionAbout()
{
return $this->render('about');
}
public function actionOrders()
{
if(Yii::$app->user->isGuest){
return $this->redirect(['site/login']);
}
return $this->render('orders');
}
public function actionGallery()
{
$gallery_model = Gallery::find()->asArray()->all();
return $this->render('gallery', compact('gallery_model'));
}
public function actionCommissions()
{
$model = new Orders();
return $this->render('commissions', ['model' => $model]);
}
public function actionStore()
{
$category = Category::find()->asArray()->all();
if(isset($_GET['id']) && $_GET['id'] != "")
{
$query = Products::find()->where(['cat_id' => $_GET['id']]);
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 8]);
$products = $query->offset($pages->offset)
->limit($pages->limit)
->all();
return $this->render('store', compact('products', 'pages', 'category'));
}else{
$query = Products::find();
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 8]);
$products = $query->offset($pages->offset)
->limit($pages->limit)
->all();
return $this->render('store', compact('products', 'pages', 'category'));
}
}
public function actionSinglproduct()
{
$minMaxPrice = array();
$prices = array();
$prices_arr = array();
$product;
if(isset($_GET['id']) && !empty($_GET['id']) && filter_var($_GET['id'], FILTER_VALIDATE_INT)){
$id = $_GET['id'];
$product = Products::find()->where(['id' => $id])->asArray()->one();
$categoryName = Category::find()->where(['id' => $product['cat_id']])->one();
if($product['price1'] > '0'){
$prices[] = $product['price1'];
$prices_arr[$product['price1']] = '6 inch - ' . $product['price1'] . ' US$+';
}
if($product['price2'] > '0'){
$prices[] = $product['price2'];
$prices_arr[$product['price2']] = '6.6 inch - ' . $product['price2'] . ' US$+';
}
if($product['price3'] > '0'){
$prices[] = $product['price3'];
$prices_arr[$product['price3']] = '7.8 inch - ' . $product['price3'] . ' US$+';
}
if($product['price4'] > '0'){
$prices[] = $product['price4'];
$prices_arr[$product['price4']] = '9 inch - ' . $product['price4'] . ' US$+';
}
$minMaxPrice[] = min($prices);
$minMaxPrice[] = max($prices);
$imgArr = explode(',', $product['img_arr']);
}
return $this->render('singlproduct', compact('product', 'imgArr', 'minMaxPrice', 'categoryName', 'prices'));
}
public function actionLk($id)
{
$user = User::find()->where(['id' => $id])->asArray()->one();
$orders = Orders::find()->where(['user_id' => $user['id']])->asArray()->all();
return $this->render('lk', ['user' => $user, 'orders' => $orders]);
}
}
Код: Выделить всё
<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap4\ActiveForm;
?>
<div class="row block">
<div class="col-lg-9 mx-auto">
<?php if(Yii::$app->session->hasFlash('success')): ?>
<div class="alert alert-success" role="alert">
<?= Yii::$app->session->getFlash('success')?>
</div>
<?php else: ?>
<div class="alert alert-danger" role="alert">
<?= Yii::$app->session->getFlash('error')?>
</div>
<?php endif; ?>
<?php if (!empty($session['cart'])):?>
<table class="table table-hover table-striped">
<thead>
<tr>
<th>Photo</th>
<th>Name</th>
<th>Count</th>
<th>Price</th>
<th>Total price</th>
<th><span><i class="fas fa-times"></i></span></th>
</tr>
</thead>
<tbody>
<?php foreach ($session['cart'] as $id => $item): ?>
<tr>
<td><img src="img/product_img/<?= $item['img']; ?>" alt="<?= $item['img']; ?>" class="modal_img"></td>
<td><a href="<?= Url::to(['site/singlproduct', 'id' => $id])?>"><?= $item['name']; ?></a></td>
<td><?= $item['qty']; ?></td>
<td>$<?= $item['price']; ?> USD</td>
<td>$<?= $item['qty'] * $item['price']; ?> USD</td>
<td><span><i class="fas fa-times text-danger del-item" data-id="<?= $id; ?>"></i></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p><b>Subtotal: <?= $session['cart.qty']?></b></p>
<p><b>Final price: $<?= $session['cart.sum']?> USD</b></p>
<hr>
<?php if(!Yii::$app->user->isGuest): ?>
<div class="col-lg-6 mx-auto">
<?php $form = ActiveForm::begin() ?>
<?= $form->field($order, 'name') ?>
<?= $form->field($order, 'address') ?>
<?= Html::submitButton('Send order', ['class' => 'btn btn-success']) ?>
<?php ActiveForm::end(); ?>
</div>
<?php else: ?>
<h3>Вы не авторизованный пользователь. Чтобы оформить заказ,
вам необходимо авторизоваться на нашем сайте. Для этого пройдите на <a href="<?=Url::ToRoute(['site/login']);?>">страницу регистрации</a>.</h3>
<?php endif; ?>
<?php else: ?>
<h3>Cart is empty :(</h3>
<?php endif; ?>
</div>
</div>
Код: Выделить всё
$(document).ready(function ($) {
$("#lightgalery").lightGallery({
});
$('.mini_img').on('click', function(){
$(this).parent('div').addClass("current").siblings().removeClass("current")
$(".main_prod_img div img").attr("src", $(this).prop("src"))
$(".main_prod_img div").attr("data-src", $(this).prop("src"))
return false;
});
$('#top-to-cart').on('click', function() {
$.ajax({
url: 'cart/show',
type: 'GET',
success: function(res){
if(res === '') alert('Error!');
showCart(res);
},
error: function(){
alert('Error!');
}
});
return false;
});
function showCart(cart) {
$('#cart .modal-body').html(cart);
$('#cart').modal();
}
$('#cart .modal-body').on('click', '.del-item', function(){
var id = $(this).data('id');
$.ajax({
url: 'cart/del-item',
data: {id: id},
type: 'GET',
success: function(res){
if(res === '') alert('Ошибка!');
showCart(res);
},
error: function(){
alert('Error');
}
});
});
$('.clearcart').on('click', function() {
$.ajax({
url: 'cart/clear',
type: 'GET',
success: function(res){
if(res === '') alert('Ошибка!');
showCart(res);
},
error: function(){
alert('Error');
}
});
});
$('.to-cart').on('click', function(e){
e.preventDefault();
var id = $(this).data('id');
var qty = $('#qty').val();
//var sise = $('#sise').val();
$.ajax({
url: 'cart/add',
data: {id: id, qty: qty},
type: 'GET',
success: function(res){
if(res === '') alert('Ошибка!');
showCart(res);
},
error: function(){
alert('Error');
}
});
});
});
Код: Выделить всё
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use app\widgets\Alert;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap4\Nav;
use yii\bootstrap4\NavBar;
use yii\bootstrap4\Breadcrumbs;
use yii\bootstrap4\Modal;
use app\assets\AppAsset;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<link rel="shortcut icon" href="/favicon.png" type="image/x-icon" />
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="top_panel container-fluid">
<div class="row">
<div class="col-lg-1">
<img src="img/mini-logo.png" alt="mini-logo">
</div>
<div class="col-lg-2">
<h1><?= Html::encode($this->title) ?></h1>
</div>
<div class="col-lg-5">
<?= Html::mailto('<i class="fas fa-envelope"></i> wolfberrycrafts.store@gmail.com', 'wolfberrycrafts.store@gmail.com') ?>
</div>
<div class="col-lg-4 d-flex justify-content-end">
<?php if(!Yii::$app->user->isGuest):?>
<a href="<?=Url::ToRoute(['/site/lk', 'id' => Yii::$app->user->identity->id]);?>" class="ml-3"><?= Yii::$app->user->identity->username ?> (Profile) <i class="fas fa-user"></i></a>
<a href="<?=Url::ToRoute(['/site/logout']);?>" class="ml-3"><?= Yii::$app->user->identity->username ?> (logout) <i class="fas fa-sign-out-alt"></i></a>
<a href="#" id="top-to-cart" class="ml-3">To cart <i class="fas fa-shopping-cart"></i></a>
<?php else : ?>
<a href="<?=Url::ToRoute(['site/login']);?>">login <i class="fas fa-sign-in-alt"></i></a>
<a href="<?=Url::ToRoute(['site/signup']);?>" class="ml-3">Signup <i class="fas fa-user-plus"></i></a>
<?php endif; ?>
</div>
</div>
</div>
<div class="logo container-fluid">
<div class="row">
<div class="logo-container">
<img src="img/logo.png" alt="logo">
</div>
</div>
</div>
<?php
NavBar::begin([
'options' => [
'class' => 'main-menu navbar-expand-lg navbar-light bg-transporant',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'Store', 'url' => ['/site/store']],
['label' => 'Commissions', 'url' => ['/site/commissions']],
['label' => 'Gallery', 'url' => ['/site/gallery']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
(Yii::$app->user->identity->role === 'admin') ? (
//['label' => 'Login', 'url' => ['/site/login']]
['label' => 'ADM', 'url' => ['/admin']]
) : (
['label' => 'Cart', 'url' => ['/cart']]
)
],
]);
NavBar::end();
?>
<?= $content ?>
<footer>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3">
<h3>Follow me</h3>
<div class="socBlockFotter">
<a id="ficon1" href="https://twitter.com/wolfberrycrafts"><span></span></a>
<a id="ficon2" href="https://www.instagram.com/wolfberrycrafts/"><span></span></a>
<a id="ficon4" href="https://aminoapps.com/c/furry-amino/page/user/radera-wolfberrycrafts/06vb_m38iafWBlxZaQ65mJDQlVaKmeb1XEf7"><span></span></a>
<a id="ficon5" href="https://www.furaffinity.net/user/wolfberrycrafts/"><span></span></a>
<a id="ficon6" href="https://www.deviantart.com/wolfberrycrafts"><span></span></a>
<a id="ficon8" href="https://www.pinterest.ru/rieluellyare/"><span></span></a>
</div>
<h3>Contact me</h3>
<div class="socBlockFotter">
<a id="ficon3" href="t.me/LynxRadera"><span></span></a>
<a id="ficon7" href="https://t.co/VBM9xNKIzq?amp=1"><span></span></a>
<a id="ficon9" href="mailto:wolfberrycraftsstore@gmail.com"><span></span></a>
</div>
</div>
<div class="col-lg-6">
<h3>Instagram</h3>
</div>
<div class="col-lg-3">
<h3>Follow my news</h3>
</div>
</div>
</div>
<div class="copyr">
<p class="pull-left">© My Company <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php
Modal::begin([
'title' => '<h2>Cart</h2>',
'id' => 'cart',
'size' => 'modal-lg',
'footer' => '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close cart</button>
<a href="' . Url::to(["cart/index"]) . '" class="btn btn-success">Make an order</a>
<button type="button" class="btn btn-danger clearcart">Clear cart</button>',
]);
Modal::end();
?>
<div class="litebox-wrap">
<img src="./img/gallery1.jpg" alt="liteboximg">
<span><i class="far fa-times-circle"></i></span>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
Код: Выделить всё
<?php
$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
'layout' => 'admin',
],
],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'umBzZRd4Pznw8foqkljkgn4lm9y3YqqV',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'wolfberrycrafts.store@gmail.com',
'password' => '',
'port' => '587',
'encryption' => 'tls',
],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'/' => 'site/index',
'store' => 'site/store',
'commissions' => 'site/commissions',
'gallery' => 'site/gallery',
'about' => 'site/about',
'contact' => 'site/contact',
'cart' => 'cart/index',
'singlproduct' => 'site/singlproduct',
],
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
return $config;
Re: Почему не открывается страница?
Точно cart? http://prntscr.com/t8b2ssKazzi писал(а): ↑2020.06.29, 10:28Смотрите.
У меня не открывается вьюха, которую использует контроллер карт. Вернее она окрывается на ОпенСервере, но после переноса на хостинг - нет. И скрипты, которые отлично работают на Локальном сервере, на хосте не работают от слова совсем.
Вот контроллер cart:
Re: Почему не открывается страница?
Вот сама ошибка:
Код: Выделить всё
1. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/View.phpat line 233
224225226227228229230231232233234235236237238239240241242 {
$viewFile = $requestedFile = Yii::getAlias($viewFile);
if ($this->theme !== null) {
$viewFile = $this->theme->applyTo($viewFile);
}
if (is_file($viewFile)) {
$viewFile = FileHelper::localize($viewFile);
} else {
throw new ViewNotFoundException("The view file does not exist: $viewFile");
}
$oldContext = $this->context;
if ($context !== null) {
$this->context = $context;
}
$output = '';
$this->_viewFiles[] = [
'resolved' => $viewFile,
2. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/View.php at line 156– yii\base\View::renderFile('/home/host1784331/host1784331.ho...', ['session' => yii\web\Session, 'order' => app\models\Orders], app\controllers\CartController)
3. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/Controller.php at line 386– yii\base\View::render('index', ['session' => yii\web\Session, 'order' => app\models\Orders], app\controllers\CartController)
4. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/controllers/CartController.php at line 42– yii\base\Controller::render('index', ['session' => yii\web\Session, 'order' => app\models\Orders])
36373839404142434445464748 $session->remove('cart.sum');
return $this->refresh();
}else{
Yii::$app->session->setFlash('error', 'Ошибка оформления заказа.');
}
}
return $this->render('index', compact('session', 'order'));
}
public function sendOrderEmailToUser($view, $session, $user) {
Yii::$app->mailer->compose('layouts/' . $view, compact('session'))
->setFrom(['wolfberrycrafts.store@gmail.com' => 'wolfberrycraft.com'])
->setTo($user->email)
5. app\controllers\CartController::actionIndex()
6. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/InlineAction.php at line 57– call_user_func_array([app\controllers\CartController, 'actionIndex'], [])
7. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/Controller.php at line 157– yii\base\InlineAction::runWithParams([])
8. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/Module.php at line 528– yii\base\Controller::runAction('index', [])
9. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/web/Application.php at line 103– yii\base\Module::runAction('cart/index', [])
10. in /home/host1784331/host1784331.hostland.pro/htdocs/www/cms/vendor/yiisoft/yii2/base/Application.php at line 386– yii\web\Application::handleRequest(yii\web\Request)
11. in /home/host1784331/host1784331.hostland.pro/htdocs/www/index.php at line 12– yii\base\Application::run()
6789101112
require __DIR__ . '/cms/vendor/autoload.php';
require __DIR__ . '/cms/vendor/yiisoft/yii2/Yii.php';
$config = require __DIR__ . '/cms/config/web.php';
(new yii\web\Application($config))->run();
$_COOKIE = [
'PHPSESSID' => '7dff8d812ab2061f7595b2b04ae533aa',
'_identity' => '9bbb79f594d96d1c068f161382ef9f419b57ad113e6e3b5f5290ac09fe78fa7ea:2:{i:0;s:9:"_identity";i:1;s:16:"[3,null,2592000]";}',
'_csrf' => 'db1c476751883e1880f994b16fedbe44c9f34b3972f4d09bac3131d6b551b8f4a:2:{i:0;s:5:"_csrf";i:1;s:32:"Px1g7-T4OpLUegjsZ4Yvn51YSU7k9vUZ";}',
];
$_SESSION = [
'__flash' => [],
'__id' => 3,
];
Yii Framework
2020-06-29, 10:30:56
Apache/2.2.35-dev (Unix) mod_ssl/2.2.35-dev OpenSSL/1.0.2k-fips Phusion_Passenger/5.1.12 PHP/7.0.33 mod_wsgi/4.6.2 Python/3.6
Yii Framework/2.0.35
Re: Почему не открывается страница?
Ой. Да, не то скинул, извиняюсь. Вот:unknownby писал(а): ↑2020.06.29, 10:31Точно cart? http://prntscr.com/t8b2ssKazzi писал(а): ↑2020.06.29, 10:28Смотрите.
У меня не открывается вьюха, которую использует контроллер карт. Вернее она окрывается на ОпенСервере, но после переноса на хостинг - нет. И скрипты, которые отлично работают на Локальном сервере, на хосте не работают от слова совсем.
Вот контроллер cart:
Код: Выделить всё
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Products;
use app\models\Cart;
use app\models\Orders;
use app\models\OrderItems;
use app\models\User;
use yii\web\Response;
class CartController extends Controller
{
public function actionIndex()
{
$session = Yii::$app->session;
$session->open();
$order = new Orders();
$user = User::findOne(Yii::$app->user->getId());
if($order->load(Yii::$app->request->post()))
{
$order->qty = $session['cart.qty'];
$order->sum = $session['cart.sum'];
$order->user_id = Yii::$app->user->getId();
if($order->save())
{
$this->saveOrderItems($session['cart'], $order->id);
Yii::$app->session->setFlash('success', 'Ваш заказ принят. Мы вскоре свяжемся с вами.');
$this->sendOrderEmailToUser('order', $session, $user);
$this->sendOrderEmailToAdmin('admin-order', $session, $order);
$session->remove('cart');
$session->remove('cart.qty');
$session->remove('cart.sum');
return $this->refresh();
}else{
Yii::$app->session->setFlash('error', 'Ошибка оформления заказа.');
}
}
return $this->render('index', compact('session', 'order'));
}
public function sendOrderEmailToUser($view, $session, $user) {
Yii::$app->mailer->compose('layouts/' . $view, compact('session'))
->setFrom(['wolfberrycrafts.store@gmail.com' => 'wolfberrycraft.com'])
->setTo($user->email)
->setSubject('Order on wulfberrycrafts.com')
->send();
}
public function sendOrderEmailToAdmin($view, $session, $order) {
Yii::$app->mailer->compose('layouts/' . $view, compact('session', 'order'))
->setFrom(['wolfberrycrafts.store@gmail.com' => 'wolfberrycraft.com'])
->setTo('wolfberrycrafts.store@gmail.com')
->setSubject('Новый заказ на wulfberrycrafts.com')
->send();
}
protected function saveOrderItems($items, $order_id)
{
foreach ($items as $id => $item) {
$order_items = new OrderItems();
$order_items->order_id = $order_id;
$order_items->product_id = $id;
$order_items->name = $item['name'];
$order_items->price = $item['price'];
$order_items->qty_item = $item['qty'];
$order_items->sum_item = $item['qty'] * $item['price'];
$order_items->save();
}
}
public function actionAdd()
{
$id = Yii::$app->request->get('id');
$qty = (int)Yii::$app->request->get('qty');
$qty = !$qty ? 1 : $qty;
//$sise = Yii::$app->request->get('sise');
$product = Products::findOne($id);
if(empty($product)) return false;
$session = Yii::$app->session;
$session->open();
$cart = new Cart();
$cart->AddToCart($product, $qty);
if (!Yii::$app->request->isAjax) {
return $this->redirect(Yii::$app->request->referrer);
}
$this->layout = false;
return $this->render('cart-modal', ['session' => $session]);
}
public function actionClear() {
$session = Yii::$app->session;
$session->open();
$session->remove('cart');
$session->remove('cart.qty');
$session->remove('cart.sum');
$this->layout = false;
return $this->render('cart-modal', ['session' => $session]);
}
public function actionDelItem() {
$id = Yii::$app->request->get('id');
$product = Products::findOne($id);
$session = Yii::$app->session;
$session->open();
$cart = new Cart();
$cart->recalc($id);
$this->layout = false;
return $this->render('cart-modal', ['session' => $session]);
}
public function actionShow() {
$session = Yii::$app->session;
$session->open();
$this->layout = false;
return $this->render('cart-modal', ['session' => $session]);
}
}
Re: Почему не открывается страница?
Для начала и проверки сделай вот такой actionIndex
А в index сделай просто отображение любого текста.
Код: Выделить всё
public function actionIndex()
{
return $this->render('index');
}
Re: Почему не открывается страница?
Все... Отбой тревоги( Я просто придурок. Я папку со вьюхами назвал с большой буквы.
- Dominus
- Сообщения: 892
- Зарегистрирован: 2013.03.14, 21:27
- Откуда: Россия, Иваново
- Контактная информация:
Re: Почему не открывается страница?
Не спорь с дураком, иначе окружающие не правильно поймут кто из вас дурак!
Re: Почему не открывается страница?
Да, я знаю( Я совсем забыл про папку( Я смотрел просто только на фалы. Столько шуму из-за одной буквы кривыми ручками.