Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap nav #3443

Closed
aripjanovsh opened this issue May 12, 2014 · 16 comments
Closed

Bootstrap nav #3443

aripjanovsh opened this issue May 12, 2014 · 16 comments
Assignees
Milestone

Comments

@aripjanovsh
Copy link

use yii\bootstrap\Nav;
$items = [
    [
        'label' => 'test 1',
        'url' => 'test',
        'items' => [
            [
                'label' => 'test 1.1',
                'url' => 'test 1.1',
                'items' => [
                    [
                        'label' => 'test 1.1.1',
                        'url' => 'test 1.1.1'
                    ],
                    [
                        'label' => 'test 1.1.2',
                        'url' => 'test 1.1.2'
                    ],
                ]
            ]
        ]
    ]
];

echo Nav::widget([
    'id' => 'topmenuleft',
    'options' => ['class' => 'navbar-nav navbar-left'],
    'items' => $items
]);

output is not correct

<ul id="topmenuleft" class="navbar-nav navbar-left nav">
    <li class="dropdown"><a class="dropdown-toggle" href="/backend/web/test" data-toggle="dropdown">test 1 <b
                class="caret"></b></a>
        <ul id="w0" class="dropdown-menu">
            <li class="dropdown-submenu"><a href="/backend/web/test 1.1" tabindex="-1">test 1.1</a>
                <ul id="w0" class="dropdown-menu">
                    <li><a href="/backend/web/test 1.1.1" tabindex="-1">test 1.1.1</a></li>
                    <li><a href="/backend/web/test 1.1.2" tabindex="-1">test 1.1.2</a></li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

identical ids id="w0" , and dropdown-submenu not working
p.s. sorry for my english :)

@cebe cebe added this to the 2.0 RC milestone May 12, 2014
@klevron
Copy link
Contributor

klevron commented May 12, 2014

Confirmed.

But submenus support in dropdown has been removed in BS3 :

Submenus just don't have much of a place on the web right now, especially the mobile web. They will be removed with 3.0 (twbs/bootstrap#6342)

http://stackoverflow.com/questions/18023493/bootstrap-3-dropdown-sub-menu-missing

@cebe
Copy link
Member

cebe commented May 12, 2014

But submenus support in dropdown has been removed in BS3 :

yeah but Nav widgets supports them. This issue is about the auto generated ids which are wrong.

@DrMabuse23
Copy link

@samdark
Copy link
Member

samdark commented Jun 23, 2014

I confirm the issue.

@arturf
Copy link
Contributor

arturf commented Jul 18, 2014

@cebe, @samdark

https://github.com/yiisoft/yii2/blob/master/extensions/bootstrap/Dropdown.php#L90

changing recursion call

$content .= $this->renderItems($item['items']);

to

$content .= static::widget([
    'items' => $item['items'],
]);

fixes problem with ids. Submit pull request?

@samdark
Copy link
Member

samdark commented Jul 18, 2014

Yes.

arturf pushed a commit to arturf/yii2 that referenced this issue Jul 18, 2014
@samdark samdark self-assigned this Jul 18, 2014
@samdark
Copy link
Member

samdark commented Jul 18, 2014

Fixed.

@qiangxue
Copy link
Member

See my comment here: #4354 (comment)

@kartik-v
Copy link
Contributor

With reference to commit e6be9fd, I maybe missing something. But I do not see containerOptions being used anywhere in the code for generating any markup. What's the purpose of this, as it causes no impact to anything yet?

Is it just to help subclass or help extend the widget?

Or do you need this to be merged with item['options']?

@samdark
Copy link
Member

samdark commented Jul 21, 2014

The purpose is to apply it to container but not to subtags.

@kartik-v
Copy link
Contributor

Ok... but if I check the Dropdown widget code, containerOptions is not used or applied anywhere.

@samdark
Copy link
Member

samdark commented Jul 21, 2014

Try it.

@kartik-v
Copy link
Contributor

I understand the recursive call and it does work (for unsetting the containerOptions['id'] after first run). But just trying to understand. The only HTML markup that uses containerOptions is this line:

return Html::tag('ul', implode("\n", $lines), $this->options);

and it does not use

return Html::tag('ul', implode("\n", $lines), $containerOptions);

Is the above correct? If so, using another class level private variable $this->_containerOptions that defaults to $this->options and with unset('id'), instead of using a function parameter $containerOptions in the renderItems method is an alternative.

@samdark
Copy link
Member

samdark commented Jul 21, 2014

Yes, it can be done that way.

@kartik-v
Copy link
Contributor

Ok. It may be better for not breaking BC.

@samdark
Copy link
Member

samdark commented Jul 21, 2014

@kartik-v can you help with testing it and a pull request?

tvdavid pushed a commit to tvdavid/yii2 that referenced this issue Jul 24, 2014
…down` were generating wrong ids for submenus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants