Open utterances-bot opened 3 years ago
hi i try to use these codes for make dynamic navbar as user can change it but my problem is how can make it responsive because it has dropdown in multilevel and i cant solve it . thnx
not sure to be honest if your using bootstrap you wrap inside .table-responsive that cuts off overflow.
If using Tailwind you can change the html at different breakpoints
Or can write media queries
thnx alot for answer me i should ask my question in different way . how can i make a dynamic navbar based on php and sql data also be responsive with multilevel submenu? i want user(client) can make change on navbar by his or herself. i dont want client need me for change navbar for them .
On Tue, Oct 27, 2020 at 6:01 PM David Carr notifications@github.com wrote:
not sure to be honest if your using bootstrap you wrap inside .table-responsive that cuts off overflow.
If using Tailwind you can change the html at different breakpoints
Or can write media queries
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dcblogdev/dcblogcomments/issues/28#issuecomment-717284626, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4MYCBBNNYMHH7KSILEL4TSM3KSNANCNFSM4S4QXOJQ .
okay, so there are 2 parts to this, updating the navbar links from normally a backend CMS/ PHP script.
Then once you have the categories and subcategories in the database you can feed that into a PHP script to show a menu, this tutorial uses a recursive function generateTree() to create the categories and subcategories. This can be turned into a navbar by placing classes on the ul and or the li items.
function generateTree($data, $parent = 0, $depth=0)
{
$tree = "<ul>\n";
for ($i=0, $ni=count($data); $i < $ni; $i++) {
if ($data[$i]['parent_id'] == $parent) {
$tree .= "<li>\n";
$tree .= $data[$i]['category'];
$tree .= generateTree($data, $data[$i]['id'], $depth+1);
$tree .= "</li>\n";
}
}
$tree .= "</ul>\n";
return $tree;
}
Those classes will be dependent on the theme/design you're using. It's outside the scope of this tutorial but you can check the $depth on each loop and apply classes to the ul element if say the $depth is more then 0
i will try it thnx u so much .have a good time
On Tue, Oct 27, 2020 at 7:32 PM David Carr notifications@github.com wrote:
okay, so there are 2 parts to this, updating the navbar links from normally a backend CMS/ PHP script.
Then once you have the categories and subcategories in the database you can feed that into a PHP script to show a menu, this tutorial uses a recursive function generateTree() to create the categories and subcategories. This can be turned into a navbar by placing classes on the ul and or the li items.
function generateTree($data, $parent = 0, $depth=0) { $tree = "
\n"; for ($i=0, $ni=count($data); $i < $ni; $i++) { if ($data[$i]['parent_id'] == $parent) {
$tree .= "<li>\n"; $tree .= $data[$i]['category']; $tree .= generateTree($data, $data[$i]['id'], $depth+1); $tree .= "</li>\n"; } } $tree .= "</ul>\n"; return $tree;
}
Those classes will be dependent on the theme/design you're using. It's outside the scope of this tutorial but you can check the $depth on each loop and apply classes to the ul element if say the $depth is more then 0
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dcblogdev/dcblogcomments/issues/28#issuecomment-717346593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4MYCCQZFN6IC6AMALJZQ3SM3VJXANCNFSM4S4QXOJQ .
MySQL categories and subcategories - DC Blog
https://dcblog.dev/mysql-categories-and-subcategories