I used the following code in my website to highlight clicked page number, but all numbers are highlighted either with clicking or not. How can I solve that?
//===================start pagination=========================
$jumpForward=3;
$jumpBackward=3;
$active=isset($_GET['page'])&&$_GET['page']==$pageNum?'active':'';
?>
<nav aria-label="Page navigation example" class="pagination-container">
<ul class="pagination pagination-lg">
<?php if( ($pageNum-$jumpBackward)>=1 ){ //previous
?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li> <?php
}else{
?> <li class="page-item disabled"><a class="page-link">Previous</a></li> <?php
}
for ($page=max(1,$pageNum-5);$page<=min($pageNum+2,$NumberOfPages);$page++) { //for loop
echo '<li class="page-item '.$active.'"><a class="page-link" href="search.php?scat='.$scat.'&c='.$count.'&i='.$catid.'&n='.$catName.'&page='.$page.'">'. $page.'</a></li>';
}
if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next
?> <li class="page-item"> <a class="page-link next" href="?
page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li> <?php
}else{
?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li> <?php
}
?>
</ul >
</nav>
<?php
}
Related
I have developed a custom taxonomy post type. I have displayed categories & inside categories posts (products).
I am getting the Post title & Image as they should be (which I add), but the descriptions of all the posts are same.
I have no idea why same desc keeps displaying, even though everything else is dynamic.
Here is the code I am using:
$taxID = get_queried_object()->term_id;
$args = array(
'post_type' => 'industrial_product',
'fields' => 'ids',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'industrial_product_cat',
'terms' => $taxID,
'field' => 'term_id',
'operator' => 'IN'
)
),
);
$query = new WP_Query($args);
if ($query->have_posts()):
$i=1;
foreach( $query->posts as $id ):?>
<div class="row mb-4">
<div class="col-md-4 col-12">
<?php
$image_palette = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
?>
<img src="<?php echo $image_palette[0]; ?>" alt="" class="img-fluid" style="max-width:100%;">
</div>
<div class="col-md-8 col-12">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item m-0" role="presentation">
<a class="nav-link active c-2" id="productInfo<?php echo $i;?>-tab" data-toggle="tab" href="#productInfo<?php echo $i;?>" role="tab" aria-controls="productInfo<?php echo $i;?>" aria-selected="true">Product Information</a>
</li>
<li class="nav-item m-0" role="presentation">
<a class="nav-link c-2" id="std_tds<?php echo $i;?>-tab" data-toggle="tab" href="#std_tds<?php echo $i;?>" role="tab" aria-controls="std_tds<?php echo $i;?>" aria-selected="false">STD / TDS</a>
</li>
</ul>
<div class="tab-content p-3" id="myTabContent<?php echo $i;?>">
<div class="tab-pane fade show active" id="productInfo<?php echo $i;?>" role="tabpanel" aria-labelledby="productInfo<?php echo $i;?>-tab">
<h5><?php echo get_the_title($id); ?></h5>
<p><?php echo get_the_content($id); ?></p>
</div>
<div class="tab-pane fade" id="std_tds<?php echo $i;?>" role="tabpanel" aria-labelledby="std_tds<?php echo $i;?>-tab">
<?php
if(get_field('std_tds_description', $id)){
the_field('std_tds_description', $id);
}
else{
echo "No, Content.";
}
?>
</div>
</div>
</div>
</div>
<?php
$i++;
endforeach;
endif;
//
}
?>
Here is a screenshot of the result:
Can somebody point out what is the problem here. I've tried all sort of stuff but It still shows same desc.
Thanks & Sorry If I'm doing something stupid, still learning!
I just changed the call
Old: <?php echo get_the_content( $id ); ?>
New: echo get_post_field('post_content', $id);
Don't know what was wrong but, It worked.
i make navbar dinamic from my table i want to take my code view to models and controler but i stuck in there i just can created in my view
My code
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<?php
$db = \Config\Database::connect();
$builder = $db->table('navbar');
$navbar = $builder->where('parent_id', '0')->where('status', '1')->orderBy('id_nav', 'ASC')->get()->getResultArray();
?>
<?php foreach ($navbar as $menu) : ?>
<?php
$db = \Config\Database::connect();
$builder = $db->table('navbar');
$subnav = $builder->where('parent_id', $menu['id_nav'])->where('status', '1')->orderBy('id_nav', 'ASC')->get()->getResultArray();
?>
<?php if ($subnav != Null) : ?>
<?php foreach ($subnav as $nav) : ?>
<li class="nav-item dropdown active">
<a class="nav-link dropdown-toggle" href="#" id="dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?= $menu['nav_name']; ?></a>
<div class="dropdown-menu" aria-labelledby="dropdown" style="border: 0px solid; background:#f8f9f9;">
<a class="dropdown-item" href="#"><?= $nav['nav_name']; ?></a>
</div>
</li>
<?php endforeach ?>
<?php else : ?>
<li class="nav-item active">
<a class="nav-link" href="#"><?= $menu['nav_name']; ?> <span class="sr-only">(current)</span></a>
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
<form class="form-inline my-2 my-md-0">
<a class="navbar-brand" href="">
<button class="btn btn-sm btn-outline-danger my-2 my-sm-0" type="submit">LOGIN</button>
<button class="btn btn-sm btn-outline-success my-4 my-sm-0" type="submit">JOIN ME</button>
</a>
</form>
</div>
</div>
</nav>
code
My Question How i put my code to Models and Controler Codeigniter4
This might help you get started How to
Read the documentation it explains everything now that it was updated.
Moreover it seems that you do not have any idea what an MVC pattern is since you are loading the db in the view. I might start from there. Model-View-Controller
I am trying to work with nav section and newly discovering it
now i want to generate an menu like following :
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>about us</li>
<li class="dropdown">
Products <span class="caret"></span>
<ul class="dropdown-menu">
<li>Products 1</li>
<li>Products 2</li>
<li>Products 3</li>
</ul>
</li>
<li>Product Support</li>
<li>Contact</li>
</ul>
</div>
With the code :
<?php echo $nav_arr = fuel_nav(array('depth'=>4
,'render_type' => 'basic'
, 'group_id' => 1
,'container_tag_attrs' => array('style' => '')
,'container_tag_class' => 'nav navbar-nav menuright'
,'order' => 'precedence'
,'subcontainer_tag_class'=>array('dropdown-menu', 'styles' => array(0 => array(1 => 'dropdown')))
)); ?>
but cant getting the way to do the changes specially in this section
<li class="dropdown">
Products <span class="caret"></span>
the out put i am getting as follow :
<div id="navbar" class="navbar-collapse collapse">
<ul style="" class="nav navbar-nav menuright">
<li class="first">Home</li>
<li>about us</li>
<li class="active"><a href="http://localhost/site/product" product-1>Product</a>
<ul style="" class="dropdown-menu">
<li class="first active">Product 1</li>
<li class="last">product-2</li>
</ul>
</li>
<li>Product Support</li>
<li class="last">Contact</li>
</ul>
</div>
can one please help me out ????please view the source code of those list
You can use array as render_type to manually generate desired tag.
Here is a example code:
<div class="collapse navbar-collapse">
<?php
$nav = fuel_nav(array('render_type' => 'array' ));
?>
<ul class="nav navbar-nav">
<?php foreach($nav as $uri=>$item):
$classes='';
$dropdown='';
if($item['nav_key'] == $page_code) $classes .=' active';
if(!empty($item['children'])) {
$classes .=' dropdown';
$dropdown ='class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"';
}
?>
<li class="<?=$classes?>">
<a href="<?=BASE_URL?><?=$item['location']?>" <?=$dropdown?> ><?=$item['label']?></a>
<?php if(!empty($item['children'])):?>
<ul class="dropdown-menu">
<?php foreach($item['children'] as $suburl=>$sub_item): ?>
<li>
<a href="<?=BASE_URL?><?=$sub_item['location']?>">
<?=$sub_item['label']?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
How to display 5 columns per row in opencart?
What I have tried is Extensions -> Modules ->Featured then edit the module. I have changed the limit to 5 and decreased the width and height but after changing it displays the same. I am not able to get five columns per row. Please suggest me how to acheve it.
Thank you.
Here is my popular.tpl file in catalog/view/theme/promoglasses/template/module
<div class="tab-title">
<h2>Popular Products</h2>
<ul class="tabs tabs-popular-products tab_categorys">
<li class="active" rel="tab129-popular-products">POPULAR Products</li>
</ul>
</div>
<br />
<br />
<br />
<div class="row">
<?php foreach ($products as $product) { ?>
<div class="product-layout col-sm-5ths">
<div class="product-thumb transition">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
<div class="caption">
<h4><?php echo $product['name']; ?></h4>
<div class="label-cont"> As low as </div>
<div class="label-price">
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="label-sup">
<b>
<sup>(C)</sup>
</b>
</div>
<br />
<p><?php echo $product['description']; ?></p>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($i = 1; $i <= 5; $i++) { ?>
<?php if ($product['rating'] < $i) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
For the CSS part here I have written the code for class col-sm-5ths:
.col-sm-5ths {
float: left;
width: 20%;
min-height: 1px;
position: relative;
}
How can I add a pagination to my isotope portfolio page?
I want each filter work with a max item of 8 and use pagination to check next 8 items.
Below is my custom Template Name: Portfolio
<?php $t =& peTheme(); ?>
<?php $title = get_the_title(); ?>
<?php $pcontent = get_the_content(); ?>
<?php $pcontent = apply_filters( 'the_content', $pcontent ); ?>
<?php $project =& $t->project; ?>
<?php list($portfolio) = $t->template->data(); ?>
<?php $content =& $t->content; ?>
<div class="container">
<div class="row">
<div class="span12">
<h1><?php echo $title; ?></h1>
</div>
</div>
<div class="row">
<div class="span12">
<nav class="portfolio-filter clearfix">
<ul>
<?php $project->filter('',"keyword"); ?>
</ul>
</nav>
</div>
<hr class="main-hr-sm">
<?php echo $pcontent; ?>
</div>
<div class="row portfolio-container">
<?php while ($content->looping()):
$meta =& $content->meta(); ?>
<div class="span3 portfolio-item <?php $project->filterClasses(); ?>">
<a href="<?php echo $t->image->resizedImgUrl($content->get_origImage(),1000,1000); ?>" class="fancybox" data-portfolio="<?php $content->slug(); ?>">
<img src="<?php echo $t->image->resizedImgUrl($content->get_origImage(),460,300); ?>" alt="<?php echo esc_html(get_the_content()); ?>">
</a>
<div class="caption">
<?php $content->content(); ?>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
Pagination isn't built into Isotope so you'd have to build it from the ground up. Here is a good tutorial on how to do that with Wordpress and Isotope v1. Keep in mind the tutorial is using Isotope v1 so you'll have to change it if you want to use Isotope v2 but the general concepts in the tutorial should still be very helpful.