I basically want to echo the number of articles on the articles index template page. I have a method in the controller. How do I echo the result of that method in the index page?
Controller
public function articleCount()
{
$article_count = $this->Articles->find('all')->count();
$this->set('article_count',$article_count );
}
index
<div class="col-xs-12 col-md-6 col-lg-3 widget">
<div class="panel panel-red panel-widget">
<div class="row no-padding">
<div class="col-sm-3 col-lg-5 widget-left">
</div>
<div class="col-sm-9 col-lg-7 widget-right">
<div class="large"><?= echo article count here! ?></div>
<div class="text-muted">Categories</div>
</div>
</div>
</div>
</div>
Im fairly new to cakephp and would appreciate any help you can give
The code you used needs to be in the index action, in the Controller:
public function index()
{
// ...
$article_count = $this->Articles->find('all')->count();
$this->set('article_count',$article_count );
// ...
}
Once you've done that, you can use the $article_count variable:
<div class="col-xs-12 col-md-6 col-lg-3 widget">
<div class="panel panel-red panel-widget">
<div class="row no-padding">
<div class="col-sm-3 col-lg-5 widget-left">
</div>
<div class="col-sm-9 col-lg-7 widget-right">
<div class="large"><?= echo $article_count ?></div>
<div class="text-muted">Categories</div>
</div>
</div>
</div>
</div>
Related
I am not even sure how to explain, so I ill just attach some pictures. Basically I have a couple of names in my DB and i am trying to display a list of them, but i would like to have 2 columns next to each other. What it does now -> https://imgur.com/ZeTiDaE and i need it to do. -> https://imgur.com/tAm3lVE
I am not really sure how to do this. Code I have:
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="col-lg-12 col-md-12 col-sm-12 headx">
<h3>Bosses</h3>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-center">
<?php while ($bosses = mysqli_fetch_assoc($kat_query)) { ?>
<?=$bosses['name']?><br />
<?php } ?>
</div>
</div>
You need to split code in two col-md-6
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="col-lg-12 col-md-12 col-sm-12 headx">
<h3>Bosses</h3>
</div>
</div>
</div>
<?php while ($boss = mysqli_fetch_assoc($kat_query)) { ?>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 text-center">
<?php echo $boss['name']; ?>
</div>
<?php $boss = mysqli_fetch_assoc($kat_query); ?>
<div class="col-lg-6 col-md-6 col-sm-6 text-center">
<?php echo $boss['name']; ?>
</div>
</div>
<?php } ?>
here is the function is given below
public function index(){
$student=Administration::Where('payment',1)->get();
//dd($student);
return view('HallAuthority.index',compact('student'));
}
Here is the view blade
<div class="container-fluid page-body-wrapper">
<div class="row row-offcanvas row-offcanvas-right">
<!-- partial:partials/_sidebar.html -->
#include('HallAuthority.inc.sidebar')
<!-- partial -->
<div class="content-wrapper">
<div class="row">
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
{{$student->count()}}
<h2 class="card-title">Total sutdent Student</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-1" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Total Department</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-2" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">stock price Price</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-3" class="card-float-chart"></div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3 grid-margin">
<div class="card">
<div class="card-body">
<h2 class="card-title">Revenue</h2>
</div>
<div class="dashboard-chart-card-container">
<div id="dashboard-card-chart-4" class="card-float-chart"></div>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<!-- partial:partials/_footer.html -->
<div class="card card-body">
<div class="card-header text-center">
Mahfujur#2019
</div>
</div>
<!-- partial -->
</div>
<!-- row-offcanvas ends -->
</div>
The Route file is given below
Route::get('/student/hall','HallController#index')->name('student.hall');
Given this type an error
Undefined variable: student (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php) (View: C:\xampp\htdocs\ProjectFinall\resources\views\HallAuthority\index.blade.php)*
I get the value properly but i cannot compact this value to the view pages its always shows that it is undefined value i am totally fed up to solve this . Please anyone help me.
Try this
public function index(){
$student=Administration::Where('payment',1)->count();
return view('HallAuthority.index',compact('student'));
}
<div class="card-body">
{{$student}}
<h2 class="card-title">Total sutdent Student</h2>
</div>
I want the information tag to be at the right side of the web page. Rest of the things are in the middle of the page. While I am not able to move the information to the right side. Also, because of it the footer disappeared. While I remove the information code, the footer works. Please help me right-align the information widget and also have the footer too.
<div class="container">
<div class="card border-light mb-3 text-center">
<p class="card-header">Videos</p>
</div>
<div id="userSuccess" class="hide" role="alert">
<div id="successUserContent"></div>
</div>
<div class="row" id="userVid">
<?php
$allVid = Schema::getAll();
for ($i = 0; $i < count($allVid); $i++) {
echo <<<HTML
<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<div class="card-body">
<img class="card-img-top" src="http://placehold.it/700x400" alt="">
<h4 class="card-title">{$allVid[$i]->getTitle()} </h4>
</div>
</div>
</div>
HTML;
}
?>
</div>
<div class="row">
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<div class="card-body">
<div class="row">
<ul class="list-unstyled mb-0">
<li>
...
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
require_once './page/footer.php';
?>
For right align, you'll want to add the class of "justify-content-end" after your "row" class.
<div class="row justify-content-end"><!-- ADDED HERE-->
<div class="col-md-4 order-md-2 mb-4">
<div class="card my-4">
<h5 class="card-header">Information</h5>
<!-- REST OF YOUR CODE-->
For your footer, you'll need to wrap your URL in parenthesis.
<?php require_once('/yourdirectory/yourfooter.php'); ?>
I am trying to hide an entire piece of CSS, a field, when the result of the vr is empty. How should I get this done? I currently managed to make sure that when the data is empty in the database, it doesn't display anything at all, otherwise it does.
<div class="row row_border">
<div class="col-md-2 col-sm-2 col-xs-3"><div class="icon"><span class="icon-tree101"></span></div></div>
<div class="col-md-10 col-sm-10 col-xs-9">
<div class="row">
<div class="col-md-12 col-sm-12"><h4>Buitenruimte</h4></div>
<div class="col-md-6 col-sm-6 list_name">
<?php if (empty(Vars::$content->object->data['obw_tuintype'])) { echo ""; } else { echo (Vars::$content->object->data['obw_tuintype']); } ?>
</div>
</div>
</div>
</div>
that's the code I have so far, thanks.
Why not put the if statement outside of the div? That way, if the element is empty, the entire div won't be displayed at all:
<?php if(!empty(Vars::$content->object->data['obw_tuintype'])){ ?>
<div class="row row_border">
<div class="col-md-2 col-sm-2 col-xs-3"><div class="icon"><span class="icon-tree101"></span></div></div>
<div class="col-md-10 col-sm-10 col-xs-9">
<div class="row">
<div class="col-md-12 col-sm-12"><h4>Buitenruimte</h4></div>
<div class="col-md-6 col-sm-6 list_name">
<?php echo (Vars::$content->object->data['obw_tuintype']); ?>
</div>
</div>
</div>
</div>
<?php } ?>
I am trying to make a dynamic column layout with the help of twitter bootstrap. All yellow blocks are generated in a for loop
Example
<div class="container">
<div class="col-lg-4">
Sidebar
</div>
<div class="col-lg-8">
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
<div class="col-lg-4"></div>
</div>
You are missing the row elements:
<div class="container">
<div class="row">
<div class="col-sm-3">
Sidebar
</div>
<div class="col-sm-9">
<div class="row">
<div class="col-sm-4">1</div>
<div class="col-sm-4">2</div>
<div class="col-sm-4">3</div>
</div>
<div class="row">
<div class="col-sm-4">4</div>
<div class="col-sm-4">5</div>
<div class="col-sm-4">6</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3">7</div>
<div class="col-sm-3">8</div>
<div class="col-sm-3">9</div>
<div class="col-sm-3">10</div>
</div>
</div>
Take a look at this demo bootply