I have a main view that is extended by different other views. Main views has a header and left sidebar.
Headers has 3 buttons with bubbles on it: Stories, New User and, Returning Users. Bubble on menu display information, like bubble on New Users shows count of visitors who signed up today.
This view is extended by all other views used in different controller methods.
This is the main view
<html>
<head>
</head>
<body>
{{-- Header--}}
<ul id="headernav">
<li>
<ul>
<li>Hoots & Stories<span>{{$todayHootStories}}</span></li>
<li>New Users<span>{{$newVisitorsToday}}</span></li>
<li>Returning Users<span>{{$retVisitorsToday}}</span></li>
</ul>
</li>
</ul>
{{-- Sidebar --}}
<nav>
<ul id="nav">
<li class="i_house">
<a href="{{route('dashboard')}}">
<span> Overview</span>
</a>
</li>
<li class="i_user">
<a href="{{route('users')}}">
<span>Users</span>
</a>
</li>
<li class="i_user">
<a href="{{route('categories')}}">
<span>Categories</span>
</a>
</li>
</ul>
</nav>
{{-- Space For Content --}}
<div id="content">
#yield('content')
</div>
</body>
</html>
Header needs three variables $todayHootStories, $newVisitorsToday, $retVisitorsToday. Now i need to include these variables from each method of different controllers to make it work properly.
Is there any other way around?
I think you are looking for View composers
View::composer('profile', function($view)
{
$view->with('count', User::count());
});
You can find a good tutorial on adding this to your layout here.
Related
I am trying to create master page layout in conditioner.But problem is that .I am getting page load error .
I have Header.php ,footer.php ,sidebar.php
Dashboar_view.php page is this
<?php include_once('common/header.php');?>
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
Dashboard
</li>
<li class="breadcrumb-item active">My Dashboard</li>
</ol>
</div>
<!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
<?php $this->load->view($content); ?>
</div>
<!-- /.container-fluid-->
<!-- /.content-wrapper-->
<?php require_once('common/footer.php');?>
And here is my controller function Dashboard.php
public function viewchart()
{
$data = array('content'=>'viewchart');
$this->load->view('admin/dashborad_view',$data);
}
getting error
Unable to load the requested file: viewchart.php.
nay help regarding create dynamic master layout for page content load.
Thanks
Hope this will help you :
if charts_view.php is a file in view folder you want to show in your dashboard
Your controller should be like this :
public function viewchart()
{
$chart_content = $this->load->view('charts_view',TRUE);
$data = array('chart_content'=> $chart_content);
$this->load->view('admin/dashborad_view',$data);
}
Your view should be like this :
<?php include_once('common/header.php');?>
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
Dashboard
</li>
<li class="breadcrumb-item active">My Dashboard</li>
</ol>
</div>
<!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
<?php echo $chart_content; ?>
</div>
<?php require_once('common/footer.php');?>
for more : https://www.codeigniter.com/user_guide/general/views.html#returning-views-as-data
I have breadcrumbs in my master.blade.php file and i want the breadcrumbs to be used everywhere BUT the homepage.blade.php.
right now this is how i add links to the breadcrumbs in other pages like "About".
about.blade.php:
#section('breadcrumbs')
#parent
<li class="last-breadcrumb">
About
</li>
#stop
in the master.blade.php:
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
but i don't want the breadcrumbs code to display at all when homepage.blade been used.
copying the code for each about.blade/X.blade files seems like a bad idea..
Your can set a value in your controller that you pass with the make/redirect like $data['breadcrumb'] = true and wrap your breadcrumb code in an conditional. This kind of system also works well for error and success messages since you can alse send content from your controller. Then you would send an array with values instead of true.
Blade template
<div class="container">
#if($breadcrumb)
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
#endif
</div>
You can check the URI to see if you want to display it or not. It's logic in your view which is usually frowned upon, but it's the easiest way I can come up with.
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#if(Route::uri() == '/')
<li class="last-breadcrumb">
About
</li>
#endif
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
Depending on the URI you are using for your home page, you may need to tweak the condition.
If you use #yield in your master template then it will only display content when the section has been defined. #content requires the section to be always defined.
hello so i'm trying to make a menu with css but when i try to click on an element from the menu it opens it in a new tab while i want it inside a div in the same page i'm new in css and thats my homework can you help me please and thanks
this is the code
<div id="menu"><?php include('admin/Menu/menu.php');?></div>
<div id="main">
i want the content here
</div>
this is the menu code
<ul id="menu">
<li>
Catalogue
<ul>
<li>Produits</li>
<li>Catégories</li>
<li>Marque</li>
<li>Fournisseur</li>
</ul>
</li>
<li>
Commandes
<ul>
<li>Commandes</li>
<li>Messages prédifinis</li>
</ul>
</li>
<li>
Clients
<ul>
<li>Clients <li>
<li>Pays</li>
<li>Groupes <li>
<li>Titre de civilité</li>
</ul>
</li>
<li>
Paramètres avancés
<ul>
<li>Emails</li>
<li>Images</li>
</ul>
</li>
<li>
Administration
<ul>
<li>Employés</li>
<li>Profils</li>
<li>Permission</li>
</ul>
</li>
<li>
Stats
<ul>
<li>Stats</li>
</ul>
</li>
What you could do is either something like this:
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'>
<div id='showMeContent' class='content'>
<p>This is just some basic content</p>
</div>
<div id='showThisContent' class='content'>
<p>This is also just some basic content</p>
</div>
</div>
<style>
.content { display: none; }
#showMeButton:active #showMeContent { display: block; }
#showThisButton:active #showThisContent { display: block; }
</style>
This is the closest you can get using css, but you might be able to do this a little better by using jQuery:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'></div>
<script>
$('#showMeButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is some content</p>");
});
$('#showThisButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is also some content</p>");
});
</script>
Whatever you do, you dó have to make sure you start using id tags, otherwise it just acts as a link, you can easily replace the href='#' with id='something', and then write some css or javascript which opens your content inside the div you'd like it in.
I seem to be having an issue with the pagination on the news section appending an /index/ when using the {pagination_links} tag.
My news page has a template path of news/index and the posts template is news/post.
I am using structure with the news/post as a listing attached to the news/index page, to add|edit posts.
If you have a look at the website in question: http://www.wilbyltd.co.uk/news scroll to the bottom you will see the pagination, if you click either 1|2|3 or next page or last page you will get the page requested, the url looks like /news/P6, however now on this next page if you go to the pagination again and click any of them you will notice it has gone back to page 1 and the url has /news/index it seems to be appending or inserting between links /index/.
I have tried to the paginate_base="" in the channel entry but adding a base stops the categories from having a working pagination, categories also add /index/ between the links?
I have thought of hacking the core but seems the wrong approach just in case it ever gets updated.
I have tried .htaccess to remove the index, which didn't work.
RewriteRule ^/news/index/(.+)$ /news/$1 [L]
I have looked at the config for index.php which has been taken off and .htaccess has been used.
I have looked at the channel settings.
I have tried dynamic="off"|dynamic="on"
I understand that news/index it the correct path for the page to view, but if this is the case why doesn't it pick up the pagination?
If anyone could shed some light in to this I would be really grateful, here is the code containing the pagination.
{exp:channel:entries channel="posts" limit="6" dynamic="on" paginate="bottom" orderby="entry_date" sort="desc"}
<div class="news-snippet span9">
<a href="{url_title_path=">
<div class="date-published textalign-center">
<span class="day">{entry_date format="%d"}</span><span class="day-suffix">{entry_date format="%S"}</span>
<span class="month">{entry_date format="%F"}</span>
</div>
</a>
<div class="news-snippet-body pull-right">
<div class="news-snippet-top-shadow">
<div class="news-snippet-bottom-shadow">
<a href="{url_title_path=">
<div class="news-snippet-content clearfix">
<div class="title">
<h3>{title}</h3>
</div>
{if news_feature_image}
<div class="clearfix image">
<img src="{news_feature_image}" />
</div>
{/if}
<p>{news_short_description}</p>
</div><!-- end content -->
</a>
<div class="news-snippet-options clearfix">
<div class="news-tags pull-left">
<i class="icon-tags"></i>
{exp:tagger:tags entry_id="{entry_id}" }
<span class="label label-inverse tags">{tagger:tag_name}</span>
{/exp:tagger:tags}
</div>
<div class="social-share pull-right textalign-center">
<i class="icon-random"></i>
<a class="addthis_button"url="{url_title_path="title="{title}" href="http://www.addthis.com/bookmark.php?v=300&pubid=ra-5141a60a37fa6e4e">Share</a>
</div>
</div>
</div><!-- end bottom-shadow -->
</div><!-- end top-shadow -->
</div><!-- end snippet-body -->
</div><!-- end news-snippet -->
{paginate}
<div class="clearfix paginate">
{pagination_links}
<div class="total-pages pull-left">
<p>Page {current_page} of {total_pages} pages</p>
</div>
<div class="pagination pagination-mini pull-right">
<ul>
{first_page}
<li>First Page</li>
{/first_page}
{previous_page}
<li>Previous Page</li>
{/previous_page}
{page}
<li>{pagination_page_number}</li>
{/page}
{next_page}
<li>Next Page</li>
{/next_page}
{last_page}
<li>Last Page</li>
{/last_page}
</ul>
</div>
{/pagination_links}
</div><!-- end clearfix -->
{/paginate}
{/exp:channel:entries}
I have also had this on Ellis Labs forum for a couple of weeks: http://ellislab.com/forums/viewthread/237601/
Try to override the {paginate_base} parameter in your channel entries tag
{exp:channel:entries channel="posts" paginate_base="news/" ...}
http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#paginate-base
I'll follow some tutorials about Laravel 3, and know, I have a problem, with one:
#section('post_navigation')
#if(Auth::check())
#include('plugins.loggedin_postnav')
#endif
#endsection
Why this section not appear?
I try remove all content in section, for example;
#section('post_navigation')
<h1>Test</h1>
#endsection
But doesn't work.
The complete code is that:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
{{ HTML::link('/', 'Instapics', array('class' => 'brand')); }}
<div class="nav-collapse">
<ul class="nav">
#section('navigation')
<li class="active">{{ HTML::link('/', 'Home') }}</li>
#yield_section
</ul>
</div>
#section('post_navigation')
#if(Auth::check())
#include('plugins.loggedin_postnav')
#endif
#endsection
</div>
</div>
</div>
[EDIT]
I change #endsection to #yield_section, and works, BUT, I still not understand, for example (in User_Controller index view):
#section('post_navigation')
#parent
#endsection
Why not appear the include?
Why I need change endsection to yield_section?
When you use #section, you define a section like defining a variable. Then, you can use it where you want by #yield('sectionname') (or by using another way I specified in the second paragraph). For example, you can look at this:
#section('scripts')
<script src="jquery.js"></script>
#endsection
<head>
#yield('scripts')
</head>
#section / #endsection and #section / #yield_section are not same. #section / #yield_section defines a section area, not a section. In other words, it calls a variable. Actually it is more similar to yield('sectionname') than #section / #endsection. It has default value as a main difference from yield.
You can define an area which has default value, and then you can change it by defining a section. This logic mostly used while creating and using layouts. For example, Let below page be our main (main.blade.php) layout.
<html>
<head>
<title>
#section('title')
Default Title Maybe Sitename.com
#yield_section
</title>
#include('scripts')
</head>
<body>
<div id="content">
#section('content')
Default content
#yield_section
</div>
<div id="sidebar">
#section('sidebar')
<ul id="menu">
<li>Menu item 1</li>
<li>Menu item 2</li>
<li>Menu item 3</li>
<li>Menu item 4</li>
</ul>
#yield_section
</body>
</html>
Generally layouts are not used directly. Another page is created and specified in the page its layout like #layout('main'). Then, sections are defined and laravel templating system change the defined section. Let this page be our post (post.blade.php) page:
#layout('main')
#section('title')
$post->title - #parent
#end_section
#section('content')
$post->content
#end_section
When we return post view View::make('profile');, as you can see, layout logic will work and sections in main.blade.php will be changed with we defined in this page. So, the output will be:
<html>
<head>
<title>
Post title - Default Title Maybe Sitename.com
</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<div id="content">
Post content
</div>
<div id="sidebar">
<ul id="menu">
<li>Menu item 1</li>
<li>Menu item 2</li>
<li>Menu item 3</li>
<li>Menu item 4</li>
</ul>
</body>
</html>
By the way, #parent returns default value in section area and #include is same logic with include in php.
Have a nice day.
Seems like you may have found an answer. But it looks like #endsection has been replaced with #stop in L4. Try something like this instead:
#section('scripts')
<script src="jquery.js"></script>
#stop