logo
down
shadow

Select a category from a dropdown list -> print the subcategories of that category in a different list


Select a category from a dropdown list -> print the subcategories of that category in a different list

By : user2947997
Date : November 14 2020, 04:48 PM
Hope this helps Read this tutorial. It will help you solve your problem. It's Ajax + Php + MySQL
PHP Ajax and MySQL
code :


Share : facebook icon twitter icon
In XCart, how can I list the subcategories within a category?

In XCart, how can I list the subcategories within a category?


By : user3417552
Date : March 29 2020, 07:55 AM
Does that help It will be better to define an array of subcategories in php script rather than do it in template. I can provide you with the following solution for your task:
Patch for include/common.php
code :
@@ -90,6 +90,14 @@
         // Get categories menu data
         if (!empty($categories)) {
             $smarty->assign('categories_menu_list', $categories);
+
+            if (!isset($cat) || 0 == intval($cat)) {
+                $extended_categories = func_get_categories_list(0, true, true, 1);
+
+                if (!empty($extended_categories)) {
+                    $smarty->assign('extended_categories_list', $extended_categories);
+                }
+            }
         }

         if ($active_modules['Manufacturers']) {
{foreach from=$categories_menu_list item=c}
<a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">
  <li>
  <img src="{$c.image_path|amp}" alt="{$c.category|escape}"/>
          <strong>{$c.category}</strong><br/>
    <!-- list subcategories here-->
    {foreach from=$extended_categories_list item=ec}
      {if $ec.parentid eq $c.categoryid}{$ec.category|escape}<br />{/if}
    {/foreach}
  </li>
</a>
{/foreach}
list all products of main category and subcategories

list all products of main category and subcategories


By : Ben
Date : March 29 2020, 07:55 AM
Hope that helps If the number of levels of hierarchy are known or assumed, you can do something like:
code :
Select Root.name
    , Level1.name As Level1Category
    , Level2.name As Level2Category
From Category As Root
    Left Join Category As Level1
        On Level1.parent = Root.id
    Left Join Category As Level2
        On Level2.parent = Level1.id
Where Root.parent = 0
Order By Root.name, Level1.name, Level2.name
Select Root.name
    , Level1.name As Level1Category
    , Level2.name As Level2Category
    , P.name As ProductName
From Category As Root
    Left Join Category As Level1
        On Level1.parent = Root.id
    Left Join Category As Level2
        On Level2.parent = Level1.id
    Join Products As P
        On P.category = Root.id
            Or P.category = Level1.id
            Or P.category = Level2.id
Where Root.parent = 0
Order By Root.name, Level1.name, Level2.name, P.name
List the subcategories of a given product category in Woocommerce

List the subcategories of a given product category in Woocommerce


By : Likhitha Jain
Date : March 29 2020, 07:55 AM
wish helps you This is possible with a custom function in which you will set your "parent" product category slug:
code :
function get_product_subcategories_list( $category_slug ){
    $terms_html = array();
    $taxonomy = 'product_cat';
    // Get the product category (parent) WP_Term object
    $parent = get_term_by( 'slug', $category_slug, $taxonomy );
    // Get an array of the subcategories IDs (children IDs)
    $children_ids = get_term_children( $parent->term_id, $taxonomy );

    // Loop through each children IDs
    foreach($children_ids as $children_id){
        $term = get_term( $children_id, $taxonomy ); // WP_Term object
        $term_link = get_term_link( $term, $taxonomy ); // The term link
        if ( is_wp_error( $term_link ) ) $term_link = '';
        // Set in an array the html formated subcategory name/link
        $terms_html[] = '<a href="' . esc_url( $term_link ) . '" rel="tag" class="' . $term->slug . '">' . $term->name . '</a>';
    }
    return '<span class="subcategories-' . $category_slug . '">' . implode( ', ', $terms_html ) . '</span>';
}
echo get_product_subcategories_list( 'clothing' );
HTML main category dropdown selection and sub-category list

HTML main category dropdown selection and sub-category list


By : user561222
Date : March 29 2020, 07:55 AM
To fix the issue you can do
Is it possible to toggle the associated sub-category div when the main-category is select?
code :
function toggleSubcatDiv( input ) {
  var name = $( input ).attr( 'name' );

  $( '.sub-list[for="' + name + '"]' )
    .siblings( '.sub-list' )
      .filter( '.active' )
        .removeClass( 'active' )
      .end()
    .end().addClass( 'active' );
}
$(".cat-dropdown-menu .cat-item").click(function() {
  var $menu = $(this).closest(".cat-dropdown-menu");
  closeMenu($menu);
  // ... your code here.

  toggleSubcatDiv( $( ':radio', this ) ); // <- here's where I used that function
});
.sub-list:not(.active) {
  display: none;
}
function toggleSubcatDiv( input ) {
  var name = $( input ).attr( 'name' );

  $( '.sub-list[for="' + name + '"]' )
    .closest( '.container' )
      .find( '.sub-list.active' )
        .removeClass( 'active' )
      .end()
    .end().addClass( 'active' );
}
Mediawiki API: How do I list all subcategories of a category?

Mediawiki API: How do I list all subcategories of a category?


By : user1580796
Date : March 29 2020, 07:55 AM
Hope that helps As the documentation mentions, you need to add cmtype=subcat to your query:
https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics&cmtype=subcat
Related Posts Related Posts :
  • How to add Smarty templating engine to CodeIgniters 3 framework?
  • Am I maxing out possible data insert
  • Redirect to homepage without changing address bar URL
  • What is the best user-Id Value for a MySql "users" table
  • PHP $_COOKIE is only available in one directory
  • php regular expressions documantation
  • cannot import too large sql file to mysql
  • not getting appilcation/json in content-type in header
  • Only the first data display from my database but other shows but not on a table
  • Is it possible to have a print button link as the content of the mail
  • how to extract full mail address in imap php
  • Alternative to output buffering to put eval'd code into a variable
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org