Hosein Shendabadi
Hosein Shendabadi

Reputation: 362

What is the best way to use one layout for different pages? (without database)

I'm working on a website and I have a layout for at least 20 services which are only different in description and image. I'm trying to find a way to implement one layout and add data for a specific link and I don't want to use a database because the data isn't important to save. Is there another way or I have to use 20 blades that extend one layout?

Upvotes: 0

Views: 45

Answers (1)

aliirfaan
aliirfaan

Reputation: 156

  1. You can have an array like this that you will pass to a layout

    $servicesLayout = [ 'service_1' => [ 'description' => 'Service 1 description', 'image' => 'www.host.com/assets/img/section_1.jpg'], 'service_2' => [ 'description' => 'Service 2 description', 'image' => 'www.host.com/assets/img/section_2.jpg'] ];

  2. Now when viewing a section, you pass the section key for example 'section_1' to the layout

  3. To display section description in layout

{{$servicesLayout['service_1']['description']}}

Upvotes: 1

Related Questions