Ahil Khan
Ahil Khan

Reputation: 217

Error Display: Syntax error, unexpected token "<" When dynamic the page title in laravel

I am make a page title dynamic if title is set in page then display it otherwise display default title

Here is below code

<title>
@yield({{ 
      @if(isset($title))
        $title
      @else 
        "Islamabad's 1st Digital Real Estate Marketplace | Property051.com"
      @endif
      }})
</title>

@extends('front.layout.app', array('title'=> $get_society->society_name))

Upvotes: -2

Views: 330

Answers (2)

Mash tan
Mash tan

Reputation: 159

I am not sure what you are even trying to do with yield. Just putting an @ before the keyword does not automatically make it into a php code. What you are trying to do should look like this.

 <title>
<?php  
      if(isset($title)){
          echo $title;
      }
      else {
        echo "Islamabad's 1st Digital Real Estate Marketplace | Property051.com";  
      }
       
      
      ?>
</title>

Upvotes: 0

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

You don't need yield here, just use:

<title>
@if(isset($title))
   {{ $title }}
@else 
   Islamabad's 1st Digital Real Estate Marketplace | Property051.com
@endif
</title>

Upvotes: 1

Related Questions