Show some navigation pages just in breadcrumbs not in top menu in zf2 - menu

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.

Related

How can I stay in the same Tab in yii2 after moving to different page in tab

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]) ?>

Issue in drupal menus

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; ?>

show some widgets from view in the left column under menue

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/

Attributes of products in cart in opencart

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.

Drupal 6- 404 is not showing for menu item URL pattern implemented using hook_menu

I have a hook menu
$items['mypage'] = array(
'title' => t('My Page title'),
'description' => '',
'type' => MENU_CALLBACK,
'page callback'=> 'my_home_page',
'access arguments' => array('access content'),
);
Now when I access a page which is not existing like "mypage/blahblah" it will show my home page(ie http://www.mydomain.com/mypage/blahblah is rendering content of http://www.mydomain.com/mypage). Instead of this I need to show a 404 page.
Can anybody give comment on this ?
You can try to paste the following code in your page call back function "my_home_page"
if ('' != arg(1)){
drupal_not_found();
}
Thanks
Rahul

Resources