target specific bootstrap tab from CodeIgniter controller - codeigniter

I use bootstrap tabs, and I would like to open specific tab from my CI controller.
Code in my view look like this:
<ul class="nav nav-tabs" id="myTabs">
<li class="active">Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li>Tab 4</li>
</ul>
Now, i would like to process some data in my controller and when done, I want to open the Tab 3
I am trying with something like this:
redirect(base_url()."hoteldetails/showHotel/".$hotelID."/#tabs1-pane3");
but the first tab is opened, instead of third tab.
Anyone can suggest some solution?
Regards, John

You could do it this way;
<?php $tab = (isset($_GET['tab'])) ? $_GET['tab'] : null; ?>
<ul class="nav nav-tabs" id="myTabs">
<li class="<?php echo ($tab == 'tab1') ? 'active' : ''; ?>">Tab 1</li>
<li class="<?php echo ($tab == 'tab2') ? 'active' : ''; ?>">Tab 2</li>
<li class="<?php echo ($tab == 'tab3') ? 'active' : ''; ?>">Tab 3</li>
<li class="<?php echo ($tab == 'tab4') ? 'active' : ''; ?>">Tab 4</li>
</ul>
Then, you should change each tab-pane, to have the active class too;
<div class="tab-pane <?php echo ($tab == 'tab1') ? 'active' : ''; ?>" id="tabs1-pane1">

Related

Laravel : how to maintain different sessions of a same page?

I need to put session on the same page sidebar. when user click on any button session will get for that tab. like
Search Job
Customers
etc
In the sidebar the button or not link with any page. i am creating a dialogue box for each so their is no page for the links that's why i am facing the problem. when user click any of the sidebar button the name should highlight.
DashboardController
public function disp()
{
Session::put('page', 'search-job');
Session::put('page', 'customer');
return view('front.disp');
}
layout.blade.php
#if(Session::get('page')=="search-job")
<?php $active = "active"; ?>
#else
<?php $active = ""; ?>
#endif
<li class="nav-item {{$active}}">
<a href="javascript:void(0)" class="nav-link nav-toggle">
<span class="title">SEARCH JOBS</span>
</a>
</li>
#if(Session::get('page')=="customer")
<?php $active = "active"; ?>
#else
<?php $active = ""; ?>
#endif
<li class="nav-item {{$active}}">
<a href="javascript:void(0)" class="nav-link nav-toggle">
<span class="title">Customer</span>
</a>
</li>
How to handle on this sidebar
Thanks!
as i understand from the comments you want to have different active sessions then you have 2 options like below:
put them in different indexes like this:
Session::put('page-search-job', true);
Session::put('page-customer', false);
and in view check them like this:
<li class="nav-item {{ Session::get('page-search-job') == true ? 'active' : '' }}">
<a href="javascript:void(0)" class="nav-link nav-toggle">
<span class="title">SEARCH JOBS</span>
</a>
</li>
put it in an array like this:
Session::put('page', [
"search-job"=>true,
"customer"=>false
]);
and in view check them like this:
<li class="nav-item {{ Session::get('page')['search-job'] == true ? 'active' : '' }}">
<a href="javascript:void(0)" class="nav-link nav-toggle">
<span class="title">SEARCH JOBS</span>
</a>
</li>

Request::is() only work on parent route. How to use that on child route?

i've tried using Request::is() for print some bootstrap class but unfortunately only work on parent route 'user', but when i using in their child not working 'user/create'
Here is my code
<ul class="dropdown-menu">
<li class="{{ Request::is('posts') ? 'active' : '' }}"><a class="nav-link" href="/posts">Posts</a></li>
<li class="{{ Request::is('posts/create') ? 'active' : '' }}"><a class="nav-link" href="/posts/create">Create New</a></li>
</ul>
u can try using (*) for any routes before or after url :
<ul class="dropdown-menu">
//post/sub_url
<li class="{{ Request::is('posts/*') ? 'active' : '' }}"><a class="nav-link" href="/posts">Posts</a></li>
//match url
<li class="{{ Request::is('posts/create') ? 'active' : '' }}"><a class="nav-link" href="/posts/create">Create New</a></li>
//match any sub_url with any prefix
<li class="{{ Request::is('*/posts/create/*') ? 'active' : '' }}"><a class="nav-link" href="/posts/create">Create New</a></li>
</ul>
Try this Request::segment(1) for parent because for child also segment(1) will be post or i prefer to put in in_array() so need i can add more route to parent active
<ul class="dropdown-menu">
<li class="{{ in_array(Request::segment(1),['post']) ? 'active' : '' }}"><a class="nav-link" href="/posts">Posts</a></li>
<li class="{{ in_array(Request::segment(1),['post']) ? 'active' : '' }}"><a class="nav-link" href="/posts/create">Create New</a></li>
</ul>

Laravel 6 multiple pagination in one page

I want to create multiple pagination in one page, info pagination is working perfectly. but
berita pagination is linked to info and always showing info page instead of berita page.
Controller
$infos = Info::paginate(4, ['*'], 'info');
$beritas = Berita::paginate(4, ['*'], 'berita');
View
{{$infos->appends(['info' => $infos->currentPage()])->links()}}
{{$beritas->appends(['berita' => $beritas->currentPage()])->links()}}
EDITED
Info
<ul class="pagination">
<li class="page-item disabled" aria-disabled="true" aria-label="« Sebelumnya">
<span class="page-link" aria-hidden="true">‹</span>
</li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="http://127.0.0.1:8000?info=2">2</a></li>
<li class="page-item">
<a class="page-link" href="http://127.0.0.1:8000?info=2" rel="next" aria-label="Berikutnya »">›</a>
</li>
</ul>
Berita
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="http://127.0.0.1:8000?berita=1" rel="prev" aria-label="« Sebelumnya">‹</a>
</li>
<li class="page-item"><a class="page-link" href="http://127.0.0.1:8000?berita=1">1</a></li>
<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>
<li class="page-item disabled" aria-disabled="true" aria-label="Berikutnya »">
<span class="page-link" aria-hidden="true">›</span>
</li>
</ul>
EDITED
Now it works, but it always show one info data inside berita pagination.
This should be possible as long as you keep track of the page value for the opposite set:
{{$infos->appends(['info' => $infos->currentPage(), 'berita' => $beritas->currentPage()])->links()}}
{{$beritas->appends(['berita' => $beritas->currentPage(), 'info' => $infos->currentPage()])->links()}}
I'll try and test this theory out later if I find time.

How to keep navigation menu state between page navigations and refresh

Im using laravel to develop a website. There is a side panel for navigating between the different pages of the website. Some pages are grouped together in an accordion (or dropdown). When I click on one of the options within the accordion it navigates to the page but the accordion closes immediately. How do I keep it open??
here is how the accordion is
<li class="treeview">
<a href="#">
<span>Group of pages</span>
<ul class="treeview-menu"
style="display: none;">
<li>
Page 1
</li>
<li>
Page 2
</li>
</ul>
</li>
Any help is appreciated.
ps. It might be worth it to add that I am using AdminLTE as a template.
Need to add Active class in li
<li class="treeview {{ ((Request::is('a-page')) || (Request::is('a-second-page')) ? 'active' : '') }}">
<a href="#">
<span>Group of pages</span>
<ul class="treeview-menu">
<li class="{{ ((Request::is('a-page')) ? 'active' : '') }}">
Page 1
</li>
<li class="{{ ((Request::is('a-second-page')) ? 'active' : '') }}">
Page 2
</li>
</ul>
</li>
OR
<li class="treeview {{ ((Route::currentRouteName() == 'a-route') || (Route::currentRouteName() == 'a-second-route') ? 'active' : '') }}">
<a href="#">
<span>Group of pages</span>
<ul class="treeview-menu">
<li class="{{ ((Route::currentRouteName() == 'a-route') ? 'active' : '') }}">
Page 1
</li>
<li class="{{ ((Route::currentRouteName() == 'a-second-route') ? 'active' : '') }}">
Page 2
</li>
</ul>
</li>

Custom output html menu in magento

basicly magento generate menu html:
<ul id="nav">
<li class="level0 nav-1 first level-top">
<span>Home</span>
</li>
<li class="level0 nav-1 first level-top parent">
<span>Category</span>
<ul class="level0">
<li class="level1 nav-2-1 first">
<span>Sub Category</span>
</li>
<li class="level1 nav-2-1">
<span>Sub Category</span>
</li>
<li class="level1 nav-2-1 last">
<span>Sub Category</span>
</li>
</ul>
</li>
</ul>
now, i want custom change output html menu (add more class html, add more element html...) somebody can help me?
There's different tutorials for doing this, but here's what I did:
Save /app/code/frontend/design/default/default/template/page/html/topmenu.phtml to /app/code/frontend/design/yourpackagename/yourthemename/template/page/html/topmenu.phtml and edit as follows:
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<li class="level0 nav-1 first level-top"><a href="/" class="level-top" ><span>Home</span></a></li>
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
To get yourpackagename and yourthemename, use System - Configuration - Design
hth, sconnie

Resources