In Joomla - limit menu depth for specific item? - joomla

In Joomla 3 - if my menu structure is:
About
Sub Item 1
Sub item 2
Products
Sub Item 1
item 1
Sub Item 2
How can I limit the depth of the menu? For Instance if I only wanted "About" to go to level 1, and "Products" to go to level 3? Is there anyway I can set it individually?
I understand I could use:
"display: none;" for the sub menu.
However - this doesn't work using a responsive framework such as foundation or bootstrap as the "has-dropdown" class triggers the dropdown menus for mobile.
Any ideas?

Two options:
Leave your menu as-is and create a second menu with aliases to the first menu with only the pages you want. This is the method I use, where the first menu is the site map and the second (and third, etc.) are for navigation menus.
On the module you're using to display the menu there is an option to limit the level of the links. This applies to the entire menu, though.

The answer is you need to un-publish the sub-menu items under the top level menu item About you do want to be displayed. I know you responded to ilias saying this would break SEF, but that isn't true. Go ahead and un-publish the sub-menu item faq, and refresh the homepage to verify sub-menu is not longer appearing. Now, navigate to the url http://www.mysite.com/about/faq and see the page still be rendered.
The un-publish is used by the mod_menu module during the HTML rendering process, the MVC path created is still valid. This is a great "best practice" to add SEF to dedicated pages with no menu header, to create an unpublished menu entry to manage the SEF silently.
Hope that helps...

Ok - as we are using Foundation 3.2.5 and Joomla - here's our solution:
In J3.2 - you can add a class to the a of each menu - we added "off"
We wrote the css for a.off to: .dropdown.off {display: none !important;}
.top-bar ul>li.has-dropdown a.off:after {display: none;}
.top-bar ul>li.has-dropdown a.off {
padding-right: 10px;
}
As we are using foundation 3.2 we rewrote the js - so that when the class a.off is there - it will go to the actual link: /*
jQuery Foundation Top Bar 2.0.4
http://foundation.zurb.com
Copyright 2012, ZURB
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
*/
/*jslint unparam: true, browser: true, indent: 2 */
(function(e,t,n){"use strict";var r={index:0,initialized:!1},i={init:function(n){return this.each(function(){r=e.extend(r,n),r.$w=e(t),r.$topbar=e("nav.top-bar"),r.$section=r.$topbar.find("section"),r.$titlebar=r.$topbar.children("ul:first");var s=e("<div class='top-bar-js-breakpoint'/>").appendTo("body");r.breakPoint=s.width(),s.remove(),r.initialized||(i.assemble(),r.initialized=!0),r.height||i.largestUL(),r.$topbar.parent().hasClass("fixed")&&e("body").css("padding-top",r.$topbar.outerHeight()),e(".top-bar .toggle-topbar").off("click.fndtn").on("click.fndtn",function(e){e.preventDefault(),i.breakpoint()&&(r.$topbar.toggleClass("expanded"),r.$topbar.css("min-height","")),r.$topbar.hasClass("expanded")||(r.$section.css({left:"0%"}),r.$section.find(">.name").css({left:"100%"}),r.$section.find("li.moved").removeClass("moved"),r.index=0)}),e(".top-bar .has-dropdown>a:not(.off)").off("click.fndtn").on("click.fndtn",function(t){(Modernizr.touch||i.breakpoint())&&t.preventDefault();if(i.breakpoint()){var n=e(this),s=n.closest("li");r.index+=1,s.addClass("moved"),r.$section.css({left:-(100*r.index)+"%"}),r.$section.find(">.name").css({left:100*r.index+"%"}),n.siblings("ul").height(r.height+r.$titlebar.outerHeight(!0)),r.$topbar.css("min-height",r.height+r.$titlebar.outerHeight(!0)*2)}}),e(t).on("resize.fndtn.topbar",function(){i.breakpoint()||r.$topbar.css("min-height","")}),e(".top-bar .has-dropdown .back").off("click.fndtn").on("click.fndtn",function(t){t.preventDefault();var n=e(this),i=n.closest("li.moved"),s=i.parent();r.index-=1,r.$section.css({left:-(100*r.index)+"%"}),r.$section.find(">.name").css({left:100*r.index+"%"}),r.index===0&&r.$topbar.css("min-height",0),setTimeout(function(){i.removeClass("moved")},300)})})},breakpoint:function(){return r.$w.width()<r.breakPoint},assemble:function(){r.$section.detach(),r.$section.find(".has-dropdown>a").each(function(){var t=e(this),n=t.siblings(".dropdown"),r=e('<li class="title back js-generated"><h5></h5></li>');r.find("h5>a").html(t.html()),n.prepend(r)}),r.$section.appendTo(r.$topbar)},largestUL:function(){var t=r.$topbar.find("section ul ul"),n=t.first(),i=0;t.each(function(){e(this).children("li").length>n.children("li").length&&(n=e(this))}),n.children("li").each(function(){i+=e(this).outerHeight(!0)}),r.height=i}};e.fn.foundationTopBar=function(t){if(i[t])return i[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t=="object"||!t)return i.init.apply(this,arguments);e.error("Method "+t+" does not exist on jQuery.foundationTopBar")};if(e(".sticky").length>0){var s=e(".sticky").length?e(".sticky").offset().top:0,o=e(t);o.scroll(function(){o.scrollTop()>=s?e(".sticky").addClass("fixed"):o.scrollTop()<s&&e(".sticky").removeClass("fixed")})}})(jQuery,this);

Related

Is it possible to remove the "new article" button from all sections in a Joomla website?

A mate and I are doing an internship at university, and the project we are working on is a small Joomla 4.1 website. Our supervisors asked us to override the mechanics of content insertion so that an article submitted by an author needs to be approved by a moderator before being featured for every visitor - as a result, we created our own Content table and a Status table linked to it. Also note that given the small scope of the website, we are also assuming a 1-to-1 correspondence between sections and categories.
The problem is that the Joomla UI lets any authenticated user upload articles and set them visible to all visitors through a "new article" button in any section. Is there a way to remove these buttons or override them with something of our own?
Haven't used the Joomla UI, but in traditional websites, you can use CSS or JS to hide/disable buttons.
For example, the "Ask Question" button in Stackoverflow (class name "aside-cta") can be disabled or hidden as follows:
CSS:
/* Disable the button */
. aside-cta {opacity: 0.1;pointer-events: none;}
/* OR hide the button */
. aside-cta {display:none }
Or Javascript can be used instead of CSS:
askBtn = document.querySelector('.aside-cta');
// For disabling the button :
askBtn.style.opacity = 0.1
askBtn.style["pointer-events"]= 'none';
// For hiding the button :
askBtn.style.display = 'none'

Top menu works with tabs. Submenu doesn't work with tabs

menu: LUCAS base_url('lucas'). submenu: deel_1 (base_url('lucas/view/1'). In controller two functions (index($choice="all) and view($choice) are going to the same view folder/page. In this page I load the particular part(lucas_tabrow_1, 2 or lucas_tabrow_all) Only the last one works! The tqo not working are coming from the submenu! Hovering over a tabrow part shows in the status: localhost/lucas/view/1#. The correct one shows: localhost/lucas#
I tried to make a tabrow with 10 menus / dropdown menus. This is too big so I try to make 2 tabrows and only load one at the time. Clicking on topmenu Lucas goes correct, but trough submenu it doesnn't work

Link directly to a notebook page in a view

I have an view that extends the current project view, where we add multiple tabs (notebook pages) to show information from other parts of a project.
One of these pages is an overview page that summarizes what is under the other tabs, and I'd like to link the headlines for each section directly to each displayed page. I've currently solved this by using the index of each tab and calling bootstrap's .tab('show') method on the link within the tab:
$(".overview-link").click(function (e) {
e.preventDefault();
var sel = '.nav-tabs a:eq(' + $(this).data('tab-index') + ')';
$(sel).tab('show');
});
This works since I've attached a data-tab-index="<int>" to each header link in my widget code, but it's brittle - if someone adds a tab later, the current indices will be broken. Earlier I relied on the anchor on each tab, but that broke as well (and would probably break if a new notebook page were inserted as well).
Triggering a web client redirect / form link directly works, but I want to show a specific page in the view:
this.do_action({
type: 'ir.actions.act_window',
res_model: 'my.model.name',
res_id: 'my.object.id',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'current'
});
Is there any way to link / redirect the web client directly to a specific notebook page tab through the do_action method or similar on FormWidget?
If I understood well you want to select the tab from the JavaScript (jQuery) FormWidget taking into account that the id could change if anybody install another module that adds another tab
Solution 0
You can add a class to the page in the xml form view. You can use the id of the element selected by this class name in order to call the right anchor and select the right tab item. This should happen when the page is completely loaded:
<page class="nb_page_to_select">
$('a[href=#' + $('.nb_page_to_select').attr('id') + ']').click()
NOTE: As you have said the following paragrah I assume that you know where to run this instruction. The solution I suggest is independent of the index.
This works since I've attached a data-tab-index="<int>" to each
header link in my widget code, but it's brittle - if someone adds a
tab later, the current indices will be broken. Earlier I relied on the
anchor on each tab, but that broke as well (and would probably break
if a new notebook page were inserted as well).
Solution 1
When the page is loaded you can get the tab list DOM object like this:
var tablist = $('ul[role="tablist"]')
And then you can click on the specifict tab, selecing by the text inside the anchor. So you don't depend on the tab index:
tablist.find('a:contains("Other Information")').click()
I think if you have two tabs with the same text does not make any sense, so this should be sufficient.
Solution 2
Even if you want to be more specific you can add a class to the notebook to make sure you are in the correct notebook
<notebook class="nt_to_change">
Now you can use one of this expressions in order to select the tab list
var tablist = $('div.nt_to_change ul.nav-tabs[role="tablist"]')
// or
var tablist = $('div.nt_to_change ul[role="tablist"]')
Solution 3
If the contains selector doesn't convince you because it should be equal you can do this as well to compare and filter
tablist.find('a').filter(function() {
return $.trim($(this).text()) === "Other Information";
}).click();
Where "Other Information" is the string of the notebook page
I didn't tried the solution I'm giving to you, but if it doesn't work at least may be it makes you come up with some idea.
There's a parameter for XML elements named autofocus (for buttons and fields is default_focus and takes 1 or 0 as value). If you add autofocus="autofocus" to a page in XML, this page will be the displayed one when you open the view.
So, you can try to add this through JavaScript, when the user clicks on the respective link -which honestly, I don't know how to achieve that by now-. But you can add a distinctive context parameter to each link in XML, for example context="{'page_to_display': 'page x'}". When you click on the link, I hope these context keys will arrive to your JS method.
If not, you can also modify the fields_view_get method (here I wrote how to do that: Odoo - Hide button for specific user) to check if you get the context you've added to your links and add the autofocus parameter to the respective page.
As you said:
This works since I've attached a data-tab-index="" to each header
link in my widget code, but it's brittle - if someone adds a tab
later, the current indices will be broken.
I assume that your app allow multi-user interaction in realtime, so you have to integrate somewhere in your code, an update part function.
This function will trig if something has changed and cleanout the data to rebuilt the index in order to avoid that the current indices will be broken.

Hide off-canvas-cart after clicked the "add to cart" button shortcode - Flatsome theme - WP

I use Flatsome theme and I am using the "add to cart" button SHORTCODE in my page with ajax activated. The redirection to cart after adding the product is disabled so user can stay in my page.
But after the button is clicked the off-canvas-cart window appears. And that is I want to stop.
see: https://www.screencast.com/t/yhmloKy7omp
I want that to stop it becose I am using the Fly Cart plugin to achieve a neat result after the add to cart btton is clicked. See: https://www.screencast.com/t/kh8fuPUT
What I have done so far:
1- I have set the cart to "link only" in Flatsome settings - https://www.screencast.com/t/pcaD4HVXIq (but that setting doesnt seem to affect the add to cart button SHORTCODE)
2- I have managed to hide the cart using css: https://www.screencast.com/t/i2YTMpLjYmqf
but I couldnt remove that top right X close button. And the user must click anywhere on the page to make the page active again and that is not a good experience.
this is the css I used:
.off-canvas-cart { display: none !important;}.mfp-bg { display: none!important;}
that is pretty much it.
This is the page: http://vendamais.me/site2/criacao-de-logotipo/
and this is the only button I am using to test the shortcode: https://www.screencast.com/t/aFgvqTbkq
(the other buttons are simple buttons ahref style, not woocommerce shortcode)
could you help me on the right direction please?
I used this:
-Set to dowpdown in the configs, then:
.nav-dropdown.nav-dropdown-default {
display: none;
visibility: hidden;
}
EDIT:
Add the li and classes to do not loose others dropdowns.
li.cart-item.has-icon.has-dropdown .nav-dropdown.nav-dropdown-default {
display: none;
visibility: hidden;
}

S5 Accordion Menu ( Mootools) changes

I'm using S5 Accordion Menu on my Joomla site.
http://jalousie.al-soft.ru/o-programme
What I need is to make it not slide down, when I reload page. It needs to work like accordion only when you click on it items, but not when the page reloads.
However it will be great, if it will be possible to save its open state for current page, but without accordion effect when page loads, just load it opened.
Sorry for my english. Let me know if you have any ideas.
Here is the source
http://jalousie.al-soft.ru/modules/mod_s5_accordion_menu/js/s5_accordion_menu.js
if you use the Accordion class that ships with mootols/more/FX just use the initialDisplayFx option to disable the initial animation. Something like the following code should work.
var s5_accordion_menu = new Accordion($('s5_accordion_menu'),
'h3.s5_am_toggler',
'div.s5_accordion_menu_element', {
opacity: true,
allowMultipleOpen: true,
display: s5_am_openElement,
alwaysHide: true,
initialDisplayFx: false
});
The signature of the class you use does not match the "official" one but maybe it is just a wrapper otherwise the answer is not, you can't disable the effect

Resources