Different default template loading even though i have set

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Different default template loading even though i have set

Post by gautamz07 »

In my views folder i have layouts/main.blade.php and under store/index.blade.php i am using the layout file like so:

Code: Select all

@extends('layouts.main') // importing here.

@section('promo')

    <section id="promo">
        <div id="promo-details">
            <h1>Today's Deals</h1>
            <p>Checkout this section of<br/>
             products at a discounted price.</p>
            <a href="#" class="default-btn">Shop Now</a>
        </div><!-- end promo-details -->
        {{ HTML::image('img/promo.png' , 'Promotional Ad') }}
    </section><!-- promo -->

@stop

@section('content')


      <h2>New Products</h2>
      <hr>
      <div id="products">
          @foreach($products as $product)
          <div class="product">
              <a href="store/view/{{ $product->id }}">
                {{ HTML::image($product->image , $product->title , array('class'=>'feature' ,
                'width'=>'240' , 'height'=>'127')) }}
              </a>

              <h3>
                <a href="/store/view/{{ $product->id }}">
                  {{ $product->title }}
                </a>
              </h3>

              <p>
                {{ $product->description }}
              </p>

              <h5>Availability:
                <span class="{{ Availability::displayClass($product->availability) }}">
                  {{ Availability::display($product->availability) }}
                </span>
              </h5>

              <p>
                  <a href="#" class="cart-btn">
                      <span class="price">${{ $product->price }}</span>
                       {{ HTML::image('img/white-cart.gif' , 'Add to Cart') }}
                        ADD TO CART
                  </a>
              </p>
          </div>
          @endforeach
      </div>  <!-- end products -->
@stop
In my storeController , i am calling the store/index.blade.php file like so:

Code: Select all

public function getIndex() {
        return View::make('store.index')
          ->with('products' , Product::take(4)->orderBy('created_at' , 'DESC')->get());
      }
In my routing file, i have the following:

Code: Select all

Route::get('/',  array('uses' => 'StoreController@getIndex'));
But still when i load my / , i get some other template rather than layouts/main.blade.php. Why is this happening ? can anybody explain ?

Why is layouts/main.blade.php not loading when i hit / in the browser ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Different default template loading even though i have se

Post by Celauran »

It looks correct at a glance. Have you checked that it isn't a caching issue? Cleared browser cache and application cache? For development, I'd turn off Laravel's cache entirely.
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: Different default template loading even though i have se

Post by gautamz07 »

I googled 'how to disable cache' ,and found this http://stackoverflow.com/questions/2057 ... right-away , really don't want to tweak my .ini file , whats the right way to turn off the cache ?
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: Different default template loading even though i have se

Post by gautamz07 »

Well i had the following syntax .

Code: Select all


<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
        {{ HTML::style('css/bootstrap.css') }}
        {{ HTML::style('css/animate.min.css') }}
        {{ HTML::style('css/style.css') }}
        {{ HTML::style('css/nprogress.css') }}
        {{ HTML::style('css/new-arrivals.css') }}

removing the below line

Code: Select all

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
solved my problem ... Why though ? also how do i disable cache in laravel during development ?
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: Different default template loading even though i have se

Post by gautamz07 »

how do i use laravel blade syntax to load a CDN

I.E.

Code: Select all

              {{ HTML::style('css/bootstrap.css') }}
works But ...

Code: Select all

        {{ HTML::src('http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css') }}
Does't .. Why ? :(
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Different default template loading even though i have se

Post by Celauran »

Any reason you wouldn't just use HTML there?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Different default template loading even though i have se

Post by Celauran »

Also, I don't see src as a method on the HTML Facade.
https://github.com/illuminate/html/blob ... uilder.php
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: Different default template loading even though i have se

Post by gautamz07 »

Thanks Celauran.
Post Reply