I'm trying to programmatically create the custom horizontal menu for my custom module, but I'm having a lot of trouble.
I want to make a horizontal menu like this :
This is my code so far, but it only displays on the main left vertical sidebar with everything else (this is the pre-packaged Garland theme):
/* hook_menu implementation for my 'lab' custom module */
function lab_menu() {
$items = array();
$items['lab/admin'] = array(
'title' => 'LAB Admin',
'page callback' => 'some_method',
'access arguments' => array('access content'),
'access callback' => 'user_access',
'type' => MENU_NORMAL_ITEM,
);
/* should appear as a 'tabbed' horizontal method */
$items['lab/admin/appoint'] = array(
'title' => 'LAB: Appointment',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
$items['lab/admin/reviewers'] = array(
'title' => 'Reviewer\'s Link',
'page callback' => 'some_method',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
Tabs like these are shown on user pages, nodes, etc.
To create a "tabs" menu like shown in the picture above in your custom module, use 'type' => MENU_LOCAL_TASK to define it as a tab on a page.
To create a second level of tabs, use a combination of 'type' => MENU_LOCAL_TASK and 'type' => MENU_DEFAULT_LOCAL_TASK
Related
I have created one product using api of shopware.
Reference: https://developers.shopware.com/developers-guide/rest-api/api-resource-article/
This product(article) is listed in Item -> Overview of shopware. But when I edit this product and try to Preview this product(article) that How it looks in front, it does not show in front. It shows :
Unfortunately, this product is no longer available.
Can Someone help me why this product is not showing in front? I want to show the article in the front which I have created using API in my Plugin.
My array for insert article data in shopware is following.
$client->post('articles',
array(
'name' => 'Damen Organic T-Shirt',
'description' => 'Description',
'descriptionLong' => 'Test Description',
'active' => 1,
'taxId' => 1,
'metaTitle' => '',
'keywords' => '',
'changetime' => date("Y-m-d H:i:s"),
'notification' => 0,
'supplier' => 'Shirtee',
'categories' => 'Shopware',
'mainDetail' => array(
'number' => 'MO1C38Q',
'inStock' => 1,
'weight' => '1.000',
'position' => '1',
'width' => null,
'height' => null,
'attribute' => array(
'attr1' => '',
),
'prices' => array(
array(
'customerGroupKey' => 'EK',
'price' => 50,
),
),
),
'images' => array(
'link' => 'test.png'
),
'configuratorSet' => array(
'groups' => array(
array(
'name' => 'Size',
'options' => 'M'
),
array(
'name' => 'Color',
'options' => 'Green'
),
)
)
));
Your answer will really help me out.
It is required to pass active => true within mainDetail as shown in the example:
$minimalTestArticle = array(
'name' => 'Sport Shoes',
'active' => true,
'tax' => 19,
'supplier' => 'Sport Shoes Inc.',
'categories' => array(
array('id' => 15),
),
'mainDetail' => array(
'number' => 'turn',
'active' => true,
'prices' => array(
array(
'customerGroupKey' => 'EK',
'price' => 999,
),
)
),
);
$client->post('articles', $minimalTestArticle);
Following is the query that you can find within engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ProductNumberService.php -> isNumberAvailable
SELECT variant.ordernumber FROM s_articles_details variant INNER JOIN s_articles product ON product.id = variant.articleID AND variant.active = 1 WHERE (variant.ordernumber = 'number') AND ((variant.laststock * variant.instock) >= (variant.laststock * variant.minpurchase)) LIMIT 1
Also, it is required to set active => true for each variation if you creating them.
I have a custom post type 'listings' and one of its taxonomies is 'status'. I want to create two widgets:
display all 'listings' WITH 'status' 'sold'.
display all 'listings' WITHOUT 'status' 'sold'.
I've achieved the first widget using
query_posts( array(
'status' => 'sold' )
);
I can't create the second widget. It should be like "status => !sold", or exclude sold. Any ideas?
Try below code when you need status = sold
$args = array(
'post_type' => 'listing',
'meta_query' => array(
array(
'key' => 'status',
'value' => 'sold',
'compare' => 'LIKE'
)
)
);
$myQuery = new WP_Query($args);
And below code when you want status != sold
$args1 = array(
'post_type' => 'listing',
'meta_query' => array(
array(
'key' => 'status',
'value' => 'sold',
'compare' => 'NOT LIKE'
)
)
);
$myQuery1 = new WP_Query($args1);
This works perfectly...
query_posts( array(
'post_type' => 'listings',
'tax_query' => array(
array(
'taxonomy' => 'status',
'field' => 'slug',
'terms' => 'sold',
'operator' => 'NOT IN'
),
)
)
);
This code excludes status => sold from post_type => listings
I have a route setup that looks like this:
Route::set('my_route', 'r/<controller>(/<action>)(/(<name>-)<hash>)', array(
'controller' => '[a-z]+',
'action' => '[a-z]+',
'hash' => '\w{13}',
'name' => '[a-z]+',
))->defaults(array(
'directory' => 'my_dir',
'controller' => 'welcome',
'action' => 'index',
'name' => null,
));
Which works by itself. The problem comes in when I try and build a URL from the route, like this:
return Route::url('my_route', array(
'action' => 'test',
));
I get this error message:
Kohana_Exception [ 0 ]: Required route parameter not passed: name
So if I set name to null, I get the same result.
If I set name to false, there is no error message, but the urls look like this:
/r/welcome/test/-
notice the - on the end?
Now I could strip that off, but I'm hoping there’s a better way.
It seems to me that you are trying to fix your routing by using 1 route for all. This is not the right way to do things.
Just make multiple routes (maybe you have to tweak this):
Route::set('my_route', 'r/<controller>(/<action>)/(<name>-)<hash>', array(
'controller' => '[a-z]+',
'action' => '[a-z]+',
'hash' => '\w{13}',
'name' => '[a-z]+',
))->defaults(array(
'directory' => 'my_dir',
'controller' => 'welcome',
'action' => 'index',
'name' => null,
));
Route::set('my_route2', 'r/<controller>(/<action>)', array(
'controller' => '[a-z]+',
'action' => '[a-z]+',
'hash' => '\w{13}',
'name' => '[a-z]+',
))->defaults(array(
'directory' => 'my_dir',
'controller' => 'welcome',
'action' => 'index',
'name' => null,
));
Remember the route system is really powerful and more routes doesn't mean it gets slower. So just make as many clearly possible routes and don't try to run everything by 1 route.
I'm looking for a way of dynamically outputting the description of my categories in my custom post type's taxonomy, but I'm over my head in php in how to achieve it. I've read the codex on category_description thorough but without any luck. Also I've looked at this guide from smashing mag.
Really hoping some php wizards can straighten me out
It should look something like this on the multiple frontend displayed custom taxonomy categories
But it looks like this
<a href="#" original-title></a>
What I'm doing is this
<?php echo '<li><a href="#" title="'.$presenter->description.'"</a></li>'; ?>
I'm declaring the $presenter variable like this
$presenter = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'portfolio' ) );
And the $presenter variable is based on my custom post_type, which is declared like this
register_post_type('portfolio', array( 'label' => 'Portfolio Items','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => '%portfolio_page%','with_front'=>true),'query_var' => true,'supports' => array('title','editor','trackbacks','revisions','thumbnail'),'labels' => array (
'name' => 'Portfolio Items',
'singular_name' => 'Portfolio Item',
'menu_name' => 'Portfolio Items',
'add_new' => 'Add Portfolio Item',
'add_new_item' => 'Add New Portfolio Item',
'edit' => 'Edit',
'edit_item' => 'Edit Portfolio Item',
'new_item' => 'New Portfolio Item',
'view' => 'View Portfolio Item',
'view_item' => 'View Portfolio Item',
'search_items' => 'Search Portfolio Items',
'not_found' => 'No Portfolio Items Found',
'not_found_in_trash' => 'No Portfolio Items Found in Trash',
'parent' => 'Parent Portfolio Item',
),) );
And my custom taxonomy is declared like this
function add_custom_taxonomies() {
register_taxonomy('p_category', 'portfolio', array(
'hierarchical' => true,
'labels' => array(
'name' => _x( 'Portfolio Category', 'taxonomy general name', 'theme_x' ),
'singular_name' => _x( 'Category', 'taxonomy singular name', 'theme_x' ),
'search_items' => __( 'Search Category', 'theme_x' ),
'all_items' => __( 'All Categories', 'theme_x' ),
'parent_item' => __( 'Parent Category', 'theme_x' ),
'parent_item_colon' => __( 'Parent Category:', 'theme_x' ),
'edit_item' => __( 'Edit Category', 'theme_x' ),
'update_item' => __( 'Update Category', 'theme_x' ),
'add_new_item' => __( 'Add New Category', 'theme_x' ),
'new_item_name' => __( 'New Category Name', 'theme_x' ),
'menu_name' => __( 'Portfolio Categories', 'theme_x' ),
),
'rewrite' => array(
'slug' => 'portfolio-category',
'with_front' => false,
'hierarchical' => true
),
)
);
};
Just in case if this helps.
You really do not need to go in that much details. Simply echo out the function category_description(), this displays out the description of the custom taxonomy term. Just make sure you have description added for your Custom taxonomy term at yourwpurl.com/wp-admin/edit-tags.php?taxonomy=custom-taxonomy-slug
I have a menu item and I want to call two functions on it. Here is my code.
$items['admin/proformative/reports'] = array(
'title' => 'report',
'page callback' => 'drupal_get_form',
'page arguments' => array('test_reports'),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
It works fine but as in page_arguments i have call one function. And Now i want to call two functions. I change the above code as following but did not work.
$items['admin/proformative/reports'] = array(
'title' => 'report',
'page callback' => 'drupal_get_form',
'page arguments' => array('test_vbo', 'test_reports'),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
But it only executes the test_vbo function and i want both to execute.
What should i need to achieve the above technique.
Your page callback is drupal_get_form, which renders the form that is returned from the page argument, which is the test_vbo function. If you want to render multiple forms, you can wrap the drupal_get_form calls in single function and use that as the page callback:
$items['admin/proformative/reports'] = array(
'title' => 'report',
'page callback' => 'test_my_function',
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
function test_my_function() {
return drupal_get_form('test_vbo') . drupal_get_form('test_reports');
}