Hybris navigation component anatomy - content-management-system

I've created CMSLinkComponent and CMSNavigationNode with the following:
$contentCatalog=myContentCatalog
$contentCV=catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]
INSERT CMSLinkComponent;$contentCV[unique=true];uid[unique=true];name;linkName[lang=en];url;&linkRef;target(code)[default='newWindow']
;;linkToOutOne;Link To Out One Name; "Link one name"; "https://google.com"; l1
;;linkToOutTwo;Link To Out Two Name; "Link two name"; "https://wikipedia.com"; l2
;;linkToOutThree;Link To Out Three Name; "Link three name"; "https://microsoft.com"; l3
INSERT CMSNavigationNode;uid[unique=true];$contentCV[unique=true];name;title[lang=en];parent(uid, $contentCV);links(&linkRef);&nodeRef
; testNavNode; ; Test Nav Node; "Node name"; NavBarNode; l1,l2; n1
Where NavBarNode is a root navigation node for the navigation component.
Import is successful and content catalog sync passes, but I can not see two links related to category in WCMS nor SmartEdit.
WCMS (Linked items is empty):
Similar in SmartEdit. Also, category and links are not visible on storefront navigation bar.
If I also import following with the above:
INSERT_UPDATE CMSNavigationEntry;uid[unique=true];$contentCV[unique=true];name;navigationNode(uid, $contentCV);item(CMSLinkComponent.uid,CMSLinkComponent.$contentCV);
;testNavEntry; ; Test Nav Entry; testNavNode; linkToOutThree
Category and link (linkToOutThree = microsoft) are now visible. I expected testNavNode to have links to google.com and wikipedia.com not microsoft.com
My questions are:
what is the purpose of links attribute(definied by CMSLinksForNavNodes relation) on CMSNavigationNode since those links are not displayed.
if CMSNavigationEntry is used to store "links" for navigation node, how to attach multiple links to same navigation node(it's navigation entry)
FYI: I'm using marketplace accelerator(client's request)

Related

How can I inherit page properties in AEM 6.2?

In our AEM 6.2 project, I ran to a scenario where I need to config a navigation in one page (let call this Homepage), all of the other pages can use home navigation config or use their own navigation config values.
I decided to use live copy because the clone pages can cancel the linked properties at any time and use their own values. But there is two problem with this approach:
Users must set the template for clone pages by edit their jcr: content/sling:resourceType and jcr: content/cq: template because the navigation is used in all pages and our web uses about 5+ templates.
Live copy does no allowed clone pages are children of source pages. But I was required to make web structure like this :
Home
|_ Page 1
|_ Page 1.1
|_ Page 2
|_ Page 3
Live copy maybe not suitable for this situation, we change to use HTL ${inheritedPageProperties}, this solve the template and structure issue but it creates two new problems:
Inherited properties in property config dialog of child page will be blank (because they are not set and called via ${inheritedPageProperties} )
If users change properties in "Page 1" page, "Page 1.1" (and Page 1.1.1, etc ...) will use these values (Because ${inheritedPageProperties} search the upper nodes to get value).
What our client want are :
All page can use navigation setting only from the homepage or their own page (use home page by default).
If use homepage properties, these values must show in their config dialog.
Try to avoid config template in CRXDE Lite
The website must have the parent-child structure
How can I achieve these requirements?
You can achieve this with a simple Sling Model and Sling's CompositeValueMap
CompositeValueMap docs state:
An implementation of the ValueMap based on two ValueMaps: - One containing the properties - Another one containing the defaults to use in case the properties map does not contain the values. In case you would like to avoid duplicating properties on multiple resources, you can use a CompositeValueMap to get a concatenated map of properties.
We can use this by supplying the descendant's value map (the current page's) then finding the correct ancestor and supplying its properties valuemap as the defaults.
for the purposes of this question, I always assume that 2rd descendant from root is always the ancestor (you can find your ancestor according to your requirnments)
package com.sample.helpers;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.CompositeValueMap;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.Self;
import javax.annotation.PostConstruct;
#Model(adaptables = Resource.class)
public class CustomInheritedPageProperties
{
ValueMap inheritedProperties;
#Self
Resource currentResource;
#OSGiService
PageManager pageManager;
#PostConstruct
protected void init() {
// get the current page, or the "descendant"
Page descendant = pageManager.getContainingPage(currentResource);
/* You have to add your custom logic to get the ancestor page.
* for this question's purposes, I'm always assuming it's the 3rd decendant of root
* more here: https://helpx.adobe.com/experience-manager/6-2/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/api/Page.html#getParent(int)
*/
Page ancestor = descendant.getParent(2);
// create a CompositeValueMap where the properties are descendant's and the defaults are ancestor's
inheritedProperties = new CompositeValueMap(descendant.getProperties(), ancestor.getProperties());
}
public ValueMap getInheritedProperties()
{
return inheritedProperties;
}
}
Now you can use this as follows
<sly data-sly-use.propHelper="com.sample.helpers.CustomInheritedPageProperties">>/sly>
<!--/* someProp here refers to the property you wish to get (inherited, of course)*/-->
<h1>propHelper.inheritedProperties.someProp</h1>

in access need to doubleclick on record in subform to show detail on main form

I have a main form with a subform. The subform is continuous and shows all of the records. The main form works great for adding and editing records. I need to be able to double click on a record in the subform and that record be displayed on the main form for editing.
By experience I reccomend you to achieve what you are trying by placing two subforms into the master one. In one you have the list and in the other the details.
In the master form you place a hidden link field that is populated when you doubleclik on the list.
This field, let´s call it [link] is the Link Master Field in the detail subform, and the Link Child Field is the id (primary key) to identify your selection.
This will link your double click (or simple) with showing the details.
I found a solution that works to move to display the record from the subform in the master for editing.
In the DblClick event on the subform I put in the following code:
Let Forms!FrmNotes.CboNotesID = TxtNotesID 'TxtNotesID is the ID on the subform
Call Me.Parent.DisplayRecord
On the main for I created
Public Sub DisplayRecord()
CboNotesID.SetFocus
DoCmd.SearchForRecord , "", acFirst, "[NotesID] = " & "'" & Screen.ActiveControl & "'"
End Sub

How to control Show/Hide fields at Runtime in Orbeon Form Runner?

I have created a form in orbeon form builder which has three 30 questions which are belongs to 3 categories. Now I don't want to show all the 30 questions to every one also I don't want to create different forms for each category because all these categories belongs to one module.
While adding the form I have a drop down question like "Select Category". If user select the first category then I need to display only first category related questions and hide the second and third category related questions.
Is there any way to achieve my task in Form Runner?
UPDATE:
#ebruchez, I have followed your suggestion, I tried testing this feature on default "contacts" form. I have created a new text field in the contact form named "Account Related Field" as a label and "control-10" as Control Name. Below is the screen shot for the same.
Then After that I clicked on control setting of the "Account Related Field" and under the "Formulas" tab I have added the following XPath expression in "Visibility" section. $topic='Account' following is the screenshot.
After adding the path expression I saved the contact form and published. Then I tried opening the form in form runner. But I am not able to view the "Account Related Field" field on UI after selecting the "topic" value is "Account" in the form runner. This is the screenshot of form runner after publishing form in form builder.
Did I miss something. Please help to resolve the issue. I need to view "Account Related Field" field only if "topic" field value is "Account"
Thanks in advance.
Yes you can, by using a "Visibility" formula under the section settings. For example if your dropdown is named foo and has two entries, category1 and category2, then you can write:
$foo = 'category1'
to make the section visible only if the dropdown selected category1, and:
$foo = 'category2'
to make the section visible only if the dropdown selected category2.
This doc might help.

Nothing appears in Typo3 with powermail (Frontend)

I need help with powermail.
I'm using Typo3 6.2.4 and powermail 2.0.16.
Something is wrong cause nothing appear in the frontend, but I don't what and I need some helps.
I created a new root page with the basic template "HELLO WORLD!" (ID = 15).
# Default PAGE object:
page = PAGE
page.10 = TEXT
page.10.value = HELLO WORLD!
In this template, I included two statics templates : "Main Template (powermail)" and "Add basic CSS (powermail)"
After that, in the root page, I created the folder "Powermail" to stock the data. (ID = 241)
And I created a second folder ("Form"; ID = 242).
In the folder "Form", I created a new Form ("registration") with the setting : Layout=Layout1; Language=Default; And the checkbox "Hide" is not checked
In this one, one Pages ("registration data") with the setting : Layout=Layout2; Language=Default; And the checkbox "Hide" is not checked
In "registration data", two fields, one for the name (Name of the sender) and one for the mail (Email of the sender) with setting : Mandatory Field=Checked; Layout=Layout3; Language=Default; And the checkbox "Hide" is not checked
And after that, in the root page, I created a new content element "powermail".
In the tab General, I set the header = Registration
In the tab Plugin, I selected Powermail. After, this is the setting : Selected Items=registration; Confirm page=checked;
Receivers Name=My Name; Receivers Email=MyName#gmail.com; Subject=My test;
Sender Name=A Name; Sender Email=AName#gmail.com; Subject=test;
In the tab Behaviour, Recursive=0 levels;
It seems that you are missing the proper typoscript to actually show the form on the page.
The specified typoscript snippet is not enough to show the content elements on the page.
Inside your typoscript template include the css_styled_content static template and change the snippet to this:
# Default PAGE object:
page = PAGE
page.10 < styles.content.get
That should ensure proper showing on the frontend. This is basic as it is, if you want it to be better looking, or different templating you should take a look at templating with TYPO3 first.

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.