Yii2 da slayder uchun dinamik rasm olib kelish bilan hatolik

0 ovoz
40 marta ko‘rilgan
so‘radi 06 mart John77 (78 bal)
tahrirlandi 06 mart Saidolim

Assalomu Aleykum, o'rnatilgan templatening slayderi uchun rasmlarni dinamik olib kelmoqchi edim. Lekin quyidagi hatolik kelib chiqdi -Undefined variable:slayd. Quyida kodlarni keltirib o'taman.

index.php

  <div class="carousel-inner">

 <?php foreach($slayd as $slayd): ?>

            <div class="item active" style="background-image: url(web/upload/<?= $slayd->image?>)">

                <div class="carousel-caption">

                    <div>

                        <h2 class="heading animated bounceInDown">Urgaz Carpets</h2>

                        <p class="animated bounceInUp">O'zbekistonda xalq istemolchilarning eng yaxshi moddalari</p>

                        <a id="read more" href="<?=\yii\helpers\Url::to(['site/about'])?>"> <button type="button" class="btn btn-success">Katalog</button></a>

                    </div>

                </div>

            </div><?php endforeach ?>            

        </div>   

model.php

  public function rules()
    {
        return [
           [['image'],'file', 'extensions' =>['png','jpg','jpeg']],
        ];
    }

public function upload()
    {
        if ($this->validate() and $this->image->baseName) {
            $this->image->saveAs(Yii::$app->basePath.'/web/upload/' . $this->image->baseName . '.' . $this->image->extension);
            return true;
        } else {
            return false;
        }
    }
   

izoh qoldirdi 06 mart Sardor Dushamov (1,440 bal)
foreachda nega ikkita birxil variable ishlatdiz, foreach($slayd as $slayd)
izoh qoldirdi 06 mart Farhodjon (979 bal)
siz controllerdan slayd degan qiymatni view ga jo'natmayapsiz. Tanimayapti slayd ni

1 ta javob

0 ovoz
javob berdi 19 mart rustam (53 bal)

rasmni nomini bazaga saqlaganmisiz? cool

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...