I have a symfony page composed of 3 parts ( and i'm using tags to display each part) by navigation menu here is the navigation menu.
<ul class="nav nav-tabs centered">
<li class="active">
{{ 'fiche_pharmacie'|trans }}
</li>
<li>
{{ 'Mon équipe'|trans }}
</li>
<li>
{{ 'Configuration_automate'|trans }}
</li>
{# <li>
{{ 'Services'|trans }}
</li> #}
</ul>
After that i call 3 twig pages to display each page content.
<div class="tab-pane" id="fiche_patient">
{{ include(':prof/Entreprise:indexdetails.html.twig') }}
</div>
<div class="tab-pane" id="my_team2">
{{ include(':prof/Entreprise:my-team.html.twig') }}
</div>
<div class="tab-pane" id="config">
{{ include(':prof/Entreprise:config.html.twig') }}
</div>
My probleme is after submit i would like to display config.html.twig page.
In my controler i tried :
return $this->redirect($this-> generateUrl('entreprise_index'.'#config'));
but it doesn't work
Any one of you have an idea ?
The correct syntax for what you are trying to do there is:
return $this->redirect($this->generateUrl('entreprise_index').'#config');
You can use redirectToRoute()
$yourRouteParams = array('param1'=>1);
return $this->redirectToRoute('entreprise_index', $yourRouteParams);
You can send the tab name as a parameter to twig. And, in the template, set the active tab according to that parameter.
Related
I'm developing landing page with October CMS and using Static Pages plugin.
Here is my header.htm file with navigation:
<div class="header" id="header">
<div class="container">
<div class="header__inner">
<div class="header__logo">
<img src="{{ 'assets/img/logo.svg'|theme }}" alt="logo" class="logo">
</div>
<nav class="nav" id="nav">
{% partial 'menu-items' items=staticMenu.menuItems class='nav__list' %}
</nav>
</div>
</div>
</div>
Question is how to modify basic menu-items.htm partial if I'am using one page layout and I want exact section be active on menu item click (not separate page as it is now).
At the moment I have menu with such items and want one of these section be active on click:
/,
/#about,
/#projects,
/#contacts.
My menu-items.htm partial is below:
<ul class="{{ class }}">
{% for item in items %}
<li
class="nav__item {{ item.isActive or item.isChildActive ? 'active' : '' }}
{{ item.items ? 'dropdown' : '' }}"
>
<a class="nav__link"
{% if item.items %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}
href="{{ item.url }}"
>
{{ item.title }}
{% if item.items %}<span class="caret"></span>{% endif %}
</a>
{% if item.items %}
{% partial 'menu-items' items=item.items class='dropdown-menu' %}
{% endif %}
</li>
{% endfor %}
</ul>
At the moment code in menu-items.htm partial if statement add "active" class on click because of this line:
<li class="nav__item {{ item.isActive or item.isChildActive ? 'active' : '' }} {{ item.items ? 'dropdown' : '' }}"
...it is because item "isActive" property is "true" when exact menu item is clicked. But my question is, how to do the same (add "active" class) with section link in meniu navigation, because my project have only one page "home" and several sections in it. so I want menu navigation link be active on fixed navigation when someone click for eaxmple "About" link and scroll to /#about section.
I wrote just several lines of Jquery (thanks to Pettis Brandon advise).
$('.nav__item').click(function(){
$('.nav__item').removeClass('active');
$(this).addClass('active')
});
It removes 'active' class from '.nav__item' class and after that add it again on corresponding link, based on {{ item.url }}. Hope it helps for the other as well (who is using Static Pages plugin).
This is the blade view to create the url links
#section ('category')
<ul class="main-categories">
#foreach($category as $category)
<li class="main-nav-list">{{ $category->category }}<span class="number">{{ $category->count}}</span></li>
#endforeach
</ul>
#endsection
when i click for the first time it's working fine and the url I get is
http://localhost/shopnew/public/glassfilm/Frosted
when I click for the secon time the url I get is
http://localhost/shopnew/public/glassfilm/glassfilm/Frosted
what I am doing wrong?
Change your route as below :
#section ('category')
<li class="main-nav-list">
<a href="{{ route('glassfilm-category',['name' => $category->category]) }}"> {{ $category->category }}
<span class="number">{{ $category->count}}</span>
</a>
</li>
#endsection
asset() method is used to include CSS/JavaScript/images files.
url() method used to generate a URL to a link.
Laravel's route() method is very helpful. So you can try:
<li class="main-nav-list">{{ $category->category }}<span class="number">{{ $category->count}}</span></li>
#section ('category')
<ul class="main-categories">
#foreach($category as $category)
<li class="main-nav-list">{{ $category->category }}<span class="number">{{ $category->count}}</span></li>
#endforeach
</ul>
#endsection
I have a filter functionality with pagination. Filter is working initially. When I click on pagination next button result is not showing based on filter.
eg: I have three countries in filter box. I chosen two then click on filter button then result is showing correct on first page but When I click on pagination next button all three countries result is showing not appending filter.
Thank you any help would be appreciated
Framework: laravel 5.5
Database: MongoDB
route.php
Route::match(['get', 'post'], '/search', 'SearchController#index')->name('search');
SearchController.php
public function index(SearchRequest $request)
{
$data = $request->all();
$cabin = Cabin::select('_id', 'name', 'country', 'region', 'interior', 'sleeping_place', 'height', 'other_details', 'interior')
->where('is_delete', 0)
->where('other_cabin', "0");
if(isset($request->cabinname)){
$cabin->where('name', $request->cabinname);
}
if(isset($request->country)){
$cabin->whereIn('country', $data['country']);
}
//dd($cabin->count());
if(isset($request->region)){
$cabin->whereIn('region', $data['region']);
}
$cabinSearchResult = $cabin->simplePaginate(5);
return view('searchResult', ['cabinSearchResult' => $cabinSearchResult]);
}
search.blade.php
<form action="{{ route('search') }}" method="POST" class="navbar-form navbar-left" id="search-nav-home">
{{ csrf_field() }}
<div class="form-group navbar-form navbar-left" id="prefetch">
<input type="text" class="form-control-home typeahead" name="cabinname" id="cabinname" placeholder="Search Cabin">
</div>
<ul class="nav navbar-nav" id="filter-home">
#if($services->country())
<li class="dropdown">
<!-- Dropdown in Filter -->
Country <span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-home">
#foreach($services->country() as $land)
<li class="check-it-list-home"><input type="checkbox" class="check-it-home" name="country[]" value="{{ $land->name }}"> {{ $land->name }}</li>
#endforeach
</ul>
</li>
#endif
#if($services->regions())
<li class="dropdown">
Region<span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-home drop-height">
#foreach($services->regions() as $region)
<li class="check-it-list-home"><input type="checkbox" name="region[]" value="{{ $region->name }}" class="check-it-home"> {{ $region->name }}
</li>
#endforeach
</ul>
</li>
#endif
</ul>
<div class="form-group navbar-form navbar-right" id="navbar-right-filter-home">
<button type="submit" class="btn btn-default-home btn-filter-home">Filter Cabins</button>
</div>
</form>
In the result View you may need to append the query link to the generated paginate link:
First in your controller, send the result of the search to the view e.g.:
....
return view('searchResult', ['cabinSearchResult' => $cabinSearchResult, 'next_query' => $data]);
Then in your View, use appends and link() method on $searchResult where you display the paginated link instead of only link() or render(), like this:
....
{{ $searchResult->appends($next_query)->links() }}
This should generate links with the query string that contains your old search query on all the pages generated.
Read more about pagination in Laravel Docs
Within a Layout
#section('breadcrumbs', Breadcrumbs::render('messages'))
#section('content')
#include('layouts.breadcrumbs')
breadcrumbs.blade.php
<div class="fluid-container">
<div class="container">
<div class="row">
<div class="col-md-12">
#yield('breadcrumbs')
</div>
</div>
</div>
</div>
Standard BS3 view with DaveJamesMillar Breadcrumbs
#if ($breadcrumbs)
<ol class="breadcrumb">
#foreach ($breadcrumbs as $breadcrumb)
#if ($breadcrumb->url && !$breadcrumb->last)
<li>{{ $breadcrumb->title }}</li>
#else
<li class="active">{{ $breadcrumb->title }}</li>
#endif
#endforeach
</ol>
#endif
Appeared to be working fine until upgrading to L5.4, now rather than displaying the breadcrumbs it displays non-processed HTML
<ol class="breadcrumb"> <li>Home</li> <li> class="active">Messages</li></ol>
After reading the latest docs for davejamesmillar laravel-breadcrumbs with support for L5.4 https://media.readthedocs.org/pdf/laravel-breadcrumbs/latest/laravel-breadcrumbs.pdf with reference to 1.4.2 using Blade Sections nothing appears to have changed in the way this needs to be coded. Unsure why the HTML is not being processed to display as a link.
RAR, hours later! Appears Laravel 5.4 runs a htmlentities when injecting a variable into a #section
I changed
#section('breadcrumbs', Breadcrumbs::render('messages'))
to
#section('breadcrumbs') {!! Breadcrumbs::Render('messages') !!} #endsection
And the html is now being processed and displayed as it should.
After changing the locale name and then print {{ Config::get('languages')[App::getLocale()] }}, it's giving me the locale name i.e. Italiano or Français. But it does not translate the website text into changed locale!
I am using following article for the localization Laravel 5.2 localization also tried Laravel Localizationbut same also there.
From my understanding, it should translate the language automatically!
Need some expert help from the community.
Sample code from my view file:
#extends('layouts.app')
#section('content')
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{ Config::get('languages')[App::getLocale()] }}
</a>
<ul class="dropdown-menu">
#foreach (Config::get('languages') as $lang => $language)
#if ($lang != App::getLocale())
<li>
{{$language}}
</li>
#endif
#endforeach
</ul>
</li>
<h2>Welcome to my website</h2>
<p>Please find your desired content by using website search function.</p>
#endsection
Are you expecting the text elements to translate? You need to use the trans() function and put your copy text in translation files.
EG
<h2>{{trans('welcome_message')}} </h2>
Then stick the copy in your language file
You are getting languages from nowhere, so if you want it to work, copy/paste following array in your app.php
'locales' => [
'en' => 'English',
'ka' => 'Georgian',
'ru' => 'Russian',
],
And if you call Config::get('app.locales') you will get this locales.
Here is how your code must look like:
#extends('layouts.app')
#section('content')
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{ Config::get('app.locales')[App::getLocale()] }}
</a>
<ul class="dropdown-menu">
#foreach (Config::get('app.locales') as $lang => $language)
#if ($lang != App::getLocale())
<li>
{{$language}}
</li>
#endif
#endforeach
</ul>
</li>
<h2>Welcome to my website</h2>
<p>Please find your desired content by using website search function.</p>
#endsection