PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun May 31, 2020 3:00 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Sep 28, 2015 7:43 am 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
In my views folder i have layouts/main.blade.php and under store/index.blade.php i am using the layout file like so:


Syntax: [ Download ] [ Hide ]
@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:

Syntax: [ Download ] [ Hide ]
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:

Syntax: [ Download ] [ Hide ]
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 ?


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 7:51 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
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.

_________________


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 2:54 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
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 ?


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 3:18 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
Well i had the following syntax .

Syntax: [ Download ] [ Hide ]

<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

Syntax: [ Download ] [ Hide ]
<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 ?


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 3:29 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
how do i use laravel blade syntax to load a CDN

I.E.

Syntax: [ Download ] [ Hide ]
              {{ HTML::style('css/bootstrap.css') }}
 


works But ...

Syntax: [ Download ] [ Hide ]
        {{ HTML::src('http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css') }}
 


Does't .. Why ? :(


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 4:56 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Any reason you wouldn't just use HTML there?

_________________


Top
 Profile  
 
PostPosted: Mon Sep 28, 2015 4:57 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Also, I don't see src as a method on the HTML Facade.
https://github.com/illuminate/html/blob ... uilder.php

_________________


Top
 Profile  
 
PostPosted: Wed Sep 30, 2015 1:25 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
Thanks Celauran.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group