How to highlight parent of the current page? - lift

How can I hightlight the parent menu item of the current page?
I have a site map as follows:
val siteMap = SiteMap(
Menu("Home") / "index",
Menu("Search") / "search" submenus (
Menu("Search Results") / "search-results") >> Hidden)
and I use it as follows:
<lift:Menu.builder ul:class="tabs" li_item:class="selected" />
However, when I navigate to the /search-results - the search menu item is no longer selected (i.e. the css class selected is no longer applied to it).
Any tips?

it's quite simple. You should use Lift built-in snippet Menu parameter li_path
something from documentation:
li_path - Adds the specified attribute
to the current page’s breadcrumb trail
(the breadcrumb trail is the set of
menu items that are direct ancestors
in the menu tree)
so in your code, you could do just:
<lift:Menu.builder ul:class="tabs" li_item:class="selected" li_path:class="selected" />
Hope this helps. If you could have any other questions just ask :)

Related

TYPO3 hide content element options in wizard

I want to show only the column options from the grid elements tab to the editors group when they create a new content element. So I tried to edit the groups TSconfig.
tx_gridelements.setup.tabs4 >
tx_gridelements.setup.tabs6 >
This has no effect. How do I remove all but the column options?
Update: With your help I figured out that my problem is not about the text in the TSconfig but that it is not loaded from the backend user group nor the beuser.
The elements you want to disable are located in Page TSconfig under mod.wizards.newContentElement.wizardItems. You can see them in the "Info" module under "Page TSconfig" :
You can simply disable them by adding
# example for the given screenshot
mod.wizards.newContentElement.wizardItems.common.elements.header >
I don't think that the answer from #statix will work with grid elements.
But in the settings of your backend layout, you can define what type of content elements are allowed within a specific content area:
And within the settings of each grid element you can define again, which content elements are available, e.g. to prevent nesting of grid elements.
Put this code in root page tscPage TSConfig
tx_gridelements.excludeLayoutIds=your grid id
May It helps you!!

using Serenity-js framework ,how to locate a shadow element whose parent has an id which is a normal DOM

please tell me how i can locate an element in the below form using serenity-js Target.
Below is my Dom to the page i am trying to automate.
so here its a dropdown which you can see as which has id="splc" which is a normal DOM .. but the content inside that dropdown are all shadow elements.
my requirement is to access the content in dropdown.
Now i am not able to even click on the dropdown by normal xpath on px-component tag ( which is normal DOM) .
Inside that px component tag I can see that it has a shadow element #label which is exact element i need to click.
Problem is in my html page , all the dropdown has the same #label as the shadow element and their parent is a normal xpath with unique id.
When i use the Jquery on the chrome console
$("html #splc /deep/ div#label").click()
i can click the desired dropdown.
But how can i do the same with serenity-js frame work.
i want to do the below functionality that i have in protractor using SERENITY-JS concept .
static dropdown = element(by.id("splc")).element(by.deepCss("#label"));
Since serenity-js expects a target always since the Task needs that in activity. How can do the same ?
please help me.
From what I can see, by.deepCss is nothing more than a wrapper around by.css:
deepCss(selector: string): Locator {
return By.css('* /deep/ ' + selector);
};
If that's the case, then the following:
element(by.id("splc")).element(by.deepCss("#label"))
could be represented as:
element(by.css("#splc /deep/ #label"))
as per your jQuery example.
Now, if the above works, you should be able to define a Target as follows:
const Dropdown = Target.the('Dropdown').located(by.css("#splc /deep/ #label"))
Hope this helps!
Jan

In CQ How to disable any field in child page properties dialog?

I have added a new selection type field "Theme" in page properties>Basic.
Now if I add a new page using the same template in WCM, there also I
am getting the option "Theme", which is quite obvious.
Is there any way by which I can hide the field in child page?
P.S this is happening because I am using the same template for the child page.
You can't use the same template and have the page property dialogs be different.
What you can do is overload the dialog
create a new template and corresponding resourceType component that
inherit from your current.
copy the dialog, or tab that you want to be different from the lowest parent of the component. Make sure the dialog is the only node under the component.
Make the changes you want to the dialog.
You would then have to include code in the page jsp to get the parent page property something like:
// if the parent page is always a certain level below the root you can use
// currentPage.getAbsoluteParent(3); to get the third page down from the top
// of the current path tree.
Page parentPage = currentPage.getParent();
ValueMap parentPageProperties;
if (parentPage != null) {
parentPageProperties = parentPage.getProperties();
}
// This tries to get the property 'theme' from the current page. If that fails
// then it tries to get the property from the parent page. If that fails it
// defaults to blank.
theme = properties.get("theme", parentPageProperties.get("theme", ""));
A quick solution would also be to create a second set of template / page component. Let's assume you've got template A, that uses page component B as resource type:
Create template X and play with allowedParents allowedChildren and allowedPaths properties so that the two are exclusive (actual solution depends on your content architecture)
Give X same title as A
Create page component Y that extends B, and defines it's own dialog
Make Y's dialog re-use any tabs from B using xtype=cqinclude (see foundation page's dialog for reference)

Can i create Customizable Menu's in umbraco

im trying to create customizable menu in umbraco. i.e. user should be able to add /remove / edit any menu item in menu. (User will not be a developer)
but i dont know how to do that..i've heard about Macros but dont know much about them so cant use it.
I think this has been done before also..
Thanks in advance
Generally, your menu will reflect your node structure within umbraco. This is the easiest way to allow your clients control of the site's navigation. If there are nodes that you would rather not have in the menu, that you could use the umbracoNaviHide property on the document type.
Try out some of the starter kits that are available. They will come with macros that build the navigation based on your nodes and will give you a good idea of how they work. You can even start by using a starterkit and then just modify it as you like. That's what I would recommend as you start out with umbraco. Umbraco has about 4 or so built in starterkits and Our Umbraco has several more that other users have contributed.
To use the default navigation template provided with Umbraco:
If you log into the Umbraco backoffice and head over to the Developer section, should should see Scripting Files. Right-click Scripting Files and choose Create. Choose a filename, like Nav and and from the "Choose a template" menu, select Site Map, then click Create. You should end up with the following razor code:
#*
SITEMAP
=================================
This snippet generates a complete sitemap of all pages that are published and visible (it'll filter out any
pages with a property named "umbracoNaviHide" that's set to 'true'). It's also a great example on how to make
helper methods in Razor and how to pass values to your '.Where' filters.
How to Customize for re-use (only applies to Macros, not if you insert this snippet directly in a template):
- If you add a Macro Parameter with the alias of "MaxLevelForSitemap" which specifies how deep in the hierarchy to traverse
How it works:
- The first line (var maxLevelForSitemap) assigns default values if none is specified via Macro Parameters
- Next is a helper method 'traverse' which uses recursion to keep making new lists for each level in the sitemap
- Inside the the 'traverse' method there's an example of using a 'Dictionary' to pass the 'maxLevelForSitemap' to
the .Where filter
- Finally the 'traverse' method is called taking the very top node of the website by calling AncesterOrSelf()
NOTE: It is safe to remove this comment (anything between # * * #), the code that generates the list is only the below!
*#
#inherits umbraco.MacroEngines.DynamicNodeContext
#helper traverse(dynamic node){
var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
var values = new Dictionary<string,object>();
values.Add("maxLevelForSitemap", maxLevelForSitemap) ;
var items = node.Children.Where("Visible").Where("Level <= maxLevelForSitemap", values);
if (items.Count() > 0) {
<ul>
#foreach (var item in items) {
<li>
#item.Name
#traverse(item)
</li>
}
</ul>
}
}
<div class="sitemap">
#traverse(#Model.AncestorOrSelf())
</div>
This will produce a ul/li menu of the structure of your site. You plug this into your template by inserting the macro.
Take a look at the default Top Navigation template for XSLT or Razor. That should give you an idea of where to start and how navigation generally works in Umbraco. I second Douglas' answer that the Navigation usually mirrors the content structure in the Content section.
If you really want a setup where you add items to the nav independent of the Content tree structure, then use a Multinode Tree Picker on your Home Page and have that be the navigation in your Top Nav macro.

Zend_Navigation: How to add numberings in the menu items?

I am generating XML from database records, then feeding it to Zend_Navigation to render it as treeview and before rendering I would like to add the level numbers, like a TOC numberings:
I have:
$partial = array('partials/menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->setUlClass('treeview')->render();
The output is dressed with ul/li(I need ul for treeview):
My First Web Page
Nice Page
Main Help
Works
But I Need:
1.My First Web Page
1.1 Nice Page
1.1.1 Main Help
1.2 Works
How can I dress each level with a number?
$navarray=$this->navigation()->menu()->toArray();
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($navarray[0]), RecursiveIteratorIterator::SELF_FIRST);
foreach ($it as $row) {
/// ????
}
Thanks Arman.
Maybe you could modify the partial to render an ol instead of ul, and then use some CSS magic to render the numbering properly.
You can see the example #48 in the Menu Helper documentation to get some inspiration.
EDIT:
If you need to use the ul tag, then probably you'll need to add the "current depth" of the menu items by hand. There is a very similar question answered here: PHP RecursiveIteratorIterator: Determining first and last item at each branch level.
Hope that helps,