My main menu is appearing through print theme function but its sub menu is not appearing..What php code is written in template.php and then in page.tpl.php to get sub menus. I am trying for two days but no positive output.
If by sub-menu you mean a secondary menu on a particular page;
create the menu in structure >> menus >> Add Menu and add your links. Then go to structure >> blocks and find the block that corresponds to your menu and set it to appear on the relevant page and position within your theme.
If you want to add it within the .tpl file you can try something like this;
<nav class="header__secondary-menu" id="secondary-menu" role="navigation">
<?php print theme('links__system_secondary_menu', array(
'links' => $secondary_menu,
'attributes' => array(
'class' => array('links', 'inline', 'clearfix'),
),
'heading' => array(
'text' => $secondary_menu_heading,
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</nav>
<?php endif; ?>
Related
I'm using Tabs widget in Yii2, and in the tabs of this widget I render 5 different views with Pagination using LinkPager, my problem is that when I click in the pagination of a Tab to go to the next page, it changes my tab to default one (The pagination changes and remains as a get parameter).
How can I stay in the same tab when moving to a different page in the same tab?
I've tried to add a parameter in Navigation that shows the active tab in the url, but pagination doesn´t work.
Here it is my navigation, I use the same format for all pagination, changing variable names for making it different:
$pagination = new Pagination([
'defaultPageSize' => 5,
'pageParam'=>'postPage',
'totalCount' => $sql->count(),
]);
Here it is my Tab widget ( I used 'active' for showing active tab as I said above, now for default shows as active first Tab)
<?php
echo Tabs::widget([
'items' => [
[
'label' => 'Actividad',
'content' => $this->render("#app/views/post/listado_posts", [
"pagination" => $paginationActividad,
"posts"=>$postsActividad,
]),
'active' => strcmp($activo, 'tabactividad')==0,
],
[
'label' => 'Posts',
'content' => $this->render("#app/views/post/listado_posts", [
"pagination" => $pagination,
"posts"=>$posts,
]),
'active' => strcmp($activo, 'tabpost')==0,
],
....
]);
?>
And finally, this is the LinkPager I use for each view:
<?= LinkPager::widget(['pagination' => $pagination]) ?>
I'd like to display custom posts from specific category in Wordpress in custom page.
My code is:
<?php $loop = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail-size', true);
?>
I'd like to display post from "loze" category.
Greetings
You can use category_name for this. Amend your WP_Query as follows:
$loop = new WP_Query(
array(
'post_type' => 'product',
'category_name' => 'loze',
'posts_per_page' => -1
)
);
However, I would recommend using the category ID instead (referenced using cat instead of category_name) as it's future-proofed somewhat (you could change the name of the category).
There is lots of information on this in the category section of the WordPress Codex for WP_Query.
I have a navigation and use it for breadcrumbs. I want to use it for top menu too , but I don't want to show my products in top menu.
How Can I achieve that ?
Add a custom attribute while defining the array in the module.config.php -
Eg:
array(
'label' => 'Product List',
'route' => 'product',
'action' => 'index',
'resource' => 'Product\Controller\Product:index',
'top_menu' => '0',
),
For the rest of the arrays set the top_menu attribute to 1.
In the partial file of top-menu, check -
<?php foreach ($this->container as $page) {
[...]
if($page->get('top_menu') == '1') {
//Code to display the menu.
}
[...]
} ?>
I hope it gives some idea.
I am working on framework yii ,I am using 2-column layout , all content from view are shown in the right column.
I want to show some widgets from view in the left column under menu. how can do it ?
Put in the widgets in the layout. Your view does not stand alone on a page, it usually stays in a layout. In the view (well not really but for the sake of the argument) I do
<?php
$this->breadcrumbs = array(
array('name' => 'Home', 'url' => array('/')),
array('name' => ($this->model->isNewRecord ? 'Create ' : 'Update ') . 'Contact',
);
?>
I can then do in the layout
<?php $this->widget('MyBreadCrumbs', array(
'crumbs' => $this->breadcrumbs,
)); ?>
Read more about the rendering process here: http://www.yiiframework.com/wiki/249/understanding-the-view-rendering-flow/
I am rather new to opencart and I'm currently developing a shop where I need to be able to display product attributes inside the cart. I searched allover but apparently no one had the need for this feature.
I short, i tried to duplicate the way attributes are retrieved in the product page but no success.
I modified the controller adding this line:
$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
I also added:
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php echo $attribute_group['name']; ?>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<?php echo $attribute['name']; ?>
<?php echo $attribute['text']; ?>
<?php } ?>
<?php } ?>
<?php } ?>
with no succes.
I guess I have to modify somehow system/library/cart.php. The problem is that I am not savvy enough to know how to do it!
At this point I decided to ask for help here!
Any ideas please?
This isn't as hard as it would seem on the surface you'll only need to edit 2 files and open 3.
--1-- Add the method for retrieving attributes to the cart class.
Open catalog/model/catalog/product.php
Find the method getProductAttributes($product_id) and copy the entire method to your clipboard.
Open system/library/cart.php and after the getProducts() method paste your copied method.
--2-- Just above where you pasted the code, at the end of the getProducts() method you'll see where the products array is built for the view, it looks similar to this:
$this->data[$key] = array(
'key' => $key,
'product_id' => $product_query->row['product_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'image' => $product_query->row['image'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $quantity,
'minimum' => $product_query->row['minimum'],
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $quantity,
'reward' => $reward * $quantity,
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $quantity : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $quantity,
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id']
);
Now simply add a call to that getAttributes method to the array:
'attributes' => $this->getProductAttributes($product_query->row['product_id'])
Now open your cart template: catalog/view/theme/yourtheme/common/cart.tpl and right where the product option loop is, you can now loop through your attributes just like the options.