RE: change menu width

ghadeer raad, modified 5 Years ago. Junior Member Posts: 51 Join Date: 6/2/20 Recent Posts
i want to change css of menu width but when i do this it's don't change ?
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Which menu? Navigation? Did you try in the browser developer tools?
Which Liferay version? Can you post your css?
ghadeer raad, modified 5 Years ago. Junior Member Posts: 51 Join Date: 6/2/20 Recent Posts
I use liferay portal 7.2 ce ga2

The control and product menu,i try change the value of this code(@media (min-width: 10px)) in the all file but i don't watch any change
This is the name of file in liferay folder(http__o_product-navigation-control-menu-theme-contributor_product_navigation_control_menu.cssEvIVODWtyBUZxhLu0qlSI-ddHNZRTqmUNHqpjphRxOM__E_DATA)
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
That sounds a lot like a generated file and not like anything you're supposed to lay your hands on.
The proper way would be to provide your own theme - this might be in the admin/control-panel theme, but I can't say for sure.
Plus, with regards to changing a min-width property: Do you see a width of less than 10 px to determine that your change doesn't work?
Patrick Yeo, modified 5 Years ago. Junior Member Posts: 61 Join Date: 2/8/13 Recent Posts
The proper way is to overwrite that file with a theme contributor. See https://help.liferay.com/hc/en-us/articles/360028726532-Packaging-Independent-UI-Resources-for-Your-Site. The issue with this method is that it will affect all Product Menus across all your sites. If you need the Product Menu styled specifically for a site, the best way is through the theme like Olaf mentioned.
Liferay Portal uses two themes, one for your public facing site and one for the admin section. Just a warning, the Product Menu styles can vary between public and admin if you don't apply your changes to both themes. To change the width of the Product Menu in your theme's _custom.scss:
@include media-breakpoint-up(sm) {
    body.open.has-control-menu {
        .control-menu {
            left: 100px;
        }        #wrapper {
            padding-left: 100px;
        }
    }    .lfr-product-menu-panel.sidenav-menu-slider:not(.lfr-admin-panel) {
        &.open,
        .sidenav-menu {
            width: 100px;
        }
    }
}
or Go to your site > site builder > pages > public pages cog icon > Insert custom CSS that is loaded after the theme
This method only applys the Product Menu styles for the public facing site
@media (min-width: 576px) {
    body.open.has-control-menu .control-menu {
        left: 100px;
    }
    body.open.has-control-menu #wrapper {
        padding-left: 100px;
    }
    .lfr-product-menu-panel.sidenav-menu-slider:not(.lfr-admin-panel).open,
    .lfr-product-menu-panel.sidenav-menu-slider:not(.lfr-admin-panel) .sidenav-menu {
        width: 100px;
    }
}
ghadeer raad, modified 5 Years ago. Junior Member Posts: 51 Join Date: 6/2/20 Recent Posts
i use liferay 7.2 CE GA2 
Ans i  need to change it in all sites of liferay in the public and admin site ,can i use contributer  with this type of liferay .
and when i put the first code you write it ?and i enter the link you share with me and read it andi show that the first way in the figure it apply to the screen not to the menu.please help me to fix this problem
Patrick Yeo, modified 5 Years ago. Junior Member Posts: 61 Join Date: 2/8/13 Recent Posts
This is hard to debug without seeing the code, but you can try making the product menu selector more specific:

#ControlMenu .lfr-product-menu-panel.sidenav-menu-slider:not(.lfr-admin-panel) {
&.open,
.sidenav-menu {
width: 100px;
}
}
}
Gadeer RK, modified 5 Years ago. Junior Member Posts: 51 Join Date: 6/2/20 Recent Posts
The problem is that i'm don't very will in design language and in liferay but my manger force me to do these action on portal i'm not very understand your comment but, do you mean i try to change code in the theme file not in the liferay file?
and first i try to make it 100px and also doesn't work then i diminish it to 10px to see the change clearly
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Gadeer RK:

The problem is that i'm don't very will in design language and in liferay but my manger force me to do these action on portal i'm not very understand your comment but, do you mean i try to change code in the theme file not in the liferay file?
If you just change random files within a Liferay installation, you'll have to remember what you did and repeat similar operations on any upgrade (see the recent security patches - you probably want to embrace them, but modified code might break the patch)
There are proper ways to extend/customize Liferay - and they're all not through modification of existing files. They're all done through configuration or deployment of custom plugins. This way you have your changes separate from the platform and are able to maintain them / upgrade to the next version.
In your case:
  • Develop a new (admin) theme
  • Configure your theme to be used, rather than the default one
In order to get a head start, you can bulk-copy the existing theme and then make it yours.  You don't need to start at zero.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Maybe you can also create your own theme contributor:
https://help.liferay.com/hc/en-us/articles/360017883032-Theme-Contributors
Theme contributors allow  you to add styles to existing themes.
Another, but rather hackish way would be to add the style directly to the pages.  (Screenshot from 7.3, but should be same in 7.2)
Click the cog on the page management page (Public or private pages) to get to the Look and Feel page of the page tree. There you can add CSS in the bottom edit box.

Please note that this isn't applied always, only when pages of this site are accessed and even if that helps you, it is very hard to maintain. After a while you will forget that you added it, something will break and you will have a hard time finding the source of that pesky style ...
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
ThemeContributors fly below my radar.
Yes, use a ThemeContributor. Thanks Patrick&Christoph for the reminder that this plugin exists as well.