Umbraco 7: create menu datatype with submenus - asp.net

How can I create a navigation menu data type with submenu items so that I can create it in the back office with properties like text, href, optional image? Something like dropdown multiple.
I've installed Umbraco 7.1.5 with NuGet in VS2013 and using Razor syntax.
EDIT:
Is it possible to create an object of type menu and edit it in the back-end's UI, for a non-developer. The user should add as many items or sub items as needed with those properties, with a plus sign. I've found this property editor. Is this possible using this property editor?

Create a Partial View (in the back-end under the SETTINGS section). If you create a new partial view, one of the pre-created snippets will be "navigation".
Then use some CSS menu (you e.g. created yourself or found on google), and try to match the navigation HTML to that of the CSS menu.
To include the partial view in the template just use
#Html.Partial("NameOfThePartialWithoutExtention")

Related

How to show specific content on a separate page using Drupal 7?

1- i have menu links HOME | Property(links to property content type) | NEWS.
2- In every News there are tags which reference to the property.
3- I want to link "NEWS" menu item to a separate page which should display only the news list which contains the tags for the property.
Example
i am on a property page say "Property XYZ", so there is a menu item "NEWS", when i click this menu item, a new page opens and this page is showing news which contain the Tag "Property XYZ" in them.
How to do this thing? Thanks in advance.
You can use the Views module to create a new View of nodes of type News, with a display of type Page (since you want the News listing to be a separate page).
Then you can add a Contextual Filter to the View, which is the way you can pass the Property as a parameter to filter to only News with that Property as a tag. You do this by adding the News field containing the tags as Contextual Filter for the view.
At this point you'll have a view page with something like 'news/%' as a path (where % is a placeholder for the Property parameter), so then you only need to use the appropriate substitution for it in each Property page for the News link on that page (like make it link to 'news/propertyxyz' while on PropertyXYZ page).
If the menu containing the NEWS menu item is outside of the scope of the Property page (like in the case of the site main menu or something like that) then you can use https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_link_alter/7.x to alter the path, getting the corresponding Property object (and any value you need to pass as parameter) through https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_object/7.x

Adobe CQ Components restricting child components

I am trying to create a component for a simple accordion, where blocks of content are held under headings and only one heading is visible at a time. My preferred implementation uses two components, one to represent the whole accordion and a second component for a single entry.
The idea is that a content author can pull the accordion in from the sidekick, then drop one or more accordion items into the accordion, but not allow any other components to be dropped here. The accordion items should only be able to be dropped into the accordion component and not within any other parsys.
My problem is that currently it is possible to add other content into the accordion and add accordion items outside of the accordion.
The first attempt to solve this was:
foobar/components/accordion
foobar/components/accordion/accordion.jsp
foobar/components/accordion/cq:editConfig
foobar/components/accordion/dialog
foobar/components/accordion/accordionitem
foobar/components/accordion/accordionitem/accordionitem.jsp
foobar/components/accordion/accordionitem/cq:editConfig
foobar/components/accordion/accordionitem/dialog
These are the config files from this are:
accordion/.content.xml
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:isContainer="{Boolean}true"
jcr:primaryType="cq:Component"
jcr:title="Accordion"
sling:resourceSuperType="foundation/components/parbase"
allowedChildren="[*/accordion/accordionitem]"
allowedParents="[*/parsys]"
componentGroup="General"/>
accordion/_cq_editConfig.xml
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:actions="[-,edit,-,delete]"
cq:layout="editbar"
jcr:primaryType="cq:EditConfig">
<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
aftercopy="REFRESH_PAGE"
afterdelete="REFRESH_PAGE"
afterinsert="REFRESH_PAGE"/>
</jcr:root>
The dialog is blank and exists only so that the component will appear in the sidekick.
accordion.jsp simply includes the foundation parsys.
accordion/accordionitem/.content.xml
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="Accordion Item"
sling:resourceSuperType="foundation/components/parbase"
allowedParents="[*/accordion]"
componentGroup="General"/>
The accordion item dialog takes in the title. The editConfig simply adds the toolbar, but no listeners.
accordionitem.jsp outputs the title taken from the dialog and has a parsys.
My problem seems to be that the parsys aren't using the rules for the accordion and accordionitem components. Instead they seem to inherit from the next parsys up instead, unless overwritten.
I can set the components correctly by using edit mode on the page and selecting the appropriate components, but that sets the information against the template, meaning I need to perform the same configuration for every page template. What I want is to have it defined in the component definition instead so that it exists once.
After first writing the components I found this blog, which describes exactly the same scenerio: http://jenikya.com/blog/2012/03/cq5-accordion-component.html
Using that as I reference, I tried adding an extension of parsys to use within accordion.jsp instead. This made no difference to the code, so even my custom parsys allowed components other than accordion item to be added.
Any guidance on either what is wrong or other approaches to take will be greatly appreciated.
The solution here would be to use a parsys and build a composite component to restrict the accordion content to a set of components only (as described in the blog entry).
Have a look at http://localhost:4502/content/geometrixx/en/company/press/asseteditor.html which also uses this technique for the dam/components/asseteditor/thumbnail component.
This is a very generic problem statement in AEM. There are several ways to handle it, depends on your business need and how your design will map this. I can suggest two solution for this:
1. Apply Template level design restriction for your accordion component. Which means, you drop accordion component and then go to design mode of page and in accordion par select accordion item component. This is one time activity only.
Though i would recommend option #2:
2. In accordion component dialog, ask author to add accordion item using multilist.
- To add a new item, simply open accordion dialog and add item in multilist and enter accordion id in it.
- To remove item, open dialog and remove item from multilist
- To change position, rearrange items in multilist.
Based on no of multilist items entered by author in Accordion dialog, statically include accordion item component and give component id entered by author in multilist.
Using this approach, you will
- easily restrict component in accordion.
- Reduce one component (accordion item) in sidekick
- Reduce one parsys on page (so many parsys eat authoring performance)

how to assign menu control to sub-node of sitemap on masterpage

i am using menu controls on my master-page and have used sitemap data-source to populate it. It shows main node on menu. is there a way that it populates the menu with sub-nodes of my master node rather than using default "home" ie masternode as starting menu item.
when you create a site map, you always design your properties in a way that it suites your web needs, They will contain, your starting node, name display, view state and autopostback.
Check your sipemapdatasource properties and your will know how to do that
You just simply put the ShowStartingNode = False in the SiteMapDataSource properties.
IT was simpler than i thoght.

Missing Dropdown in Component Styles Tab in CQ5

In the TextImage component, the Style tab has lost the css selection dropdown that used to show up when editing the component. It now just shows a blank area. It should have a dropdown for image alignment (left or right are your choices). This doesn't appear anymore.
This tab is xtype componentstyles (String), so I don't know where it references the source for the dropdown values. My local instance of CQ5 works just fine.
I cannot just add an xtype selection and feed it values because the css that gets added to the JSP code is outside the component's .jsp-specific page
It looks like the componentstyles xtype is driven by the CQ design that is associated to the page. Designs are stored underneath /etc/designs and are assigned through a page's Page properties dialog (cq:designPath property)
Let's look at an example in the Geometrixx website. If you navigate to the English homepage # /content/geometrixx/en.html and add an instance of the TextImage component to the page, you will notice that the Styles tab is empty in the component dialog. Now navigate to the 'Discover Geometrixx' page # /geometrixx/en/company/discover_geometrixx.html and examine one of the two pre-existing instances of the TextImage component. The Styles tab has the image dropdown you mentioned!
So what is the difference between the instances on the 'Discover Page' and the 'Home' page? The answer is in the design definition. If you open up CRXDE Lite and navigate to the Geometrixx design page for the Content Page template (which the 'Discover Geometrixx' page adopts), you will see the following nodes:
/etc/designs/geometrixx/jcr:content/contentpage/par/textimage
/etc/designs/geometrixx/jcr:content/contentpage/par/textimage/cq:styles
/etc/designs/geometrixx/jcr:content/contentpage/par/textimage/cq:styles/imagealign
/etc/designs/geometrixx/jcr:content/contentpage/par/textimage/cq:styles/imagealign/image_left
/etc/designs/geometrixx/jcr:content/contentpage/par/textimage/cq:styles/imagealign/image_right
The design for the Homepage template (which the 'Home' page adopts) is missing this definition.
If you want to continue to use the out of box TextImage component, it seems you will need to have this design configuration set up on all the paragraph systems and templates where the component can go. So for example, if you want these styles to be available to the TextImage component when it is added to the par paragraph system of the Homepage template, you would add similar style nodes to:
/etc/designs/geometrixx/jcr:content/homepage/par/textimage/cq:styles
Alternatively you could just overlay the component and/or create your own. Then for this custom component you could create your own Styles dialog that is independent of the design. You can simulate the out of box behavior by examining the saved JCR property and setting the appropriate CSS class name in your render script.
The problem is that a design path variable went missing. We don't know why or how, but the solution is as follows.
Open up Content Repository
Go to /content/-sitefolder-/ and expand
Click on jcr:content and view properties
Check for attribute cq:designPath and its value
/etc/designs/-sitefolder-; add to properties if it doesn't exist

ASP Menu bar, Static view

I am looking to create a menu bar with a specic type of "action"
Similar to the bar on this website
BBC Sport
Its totally static and has no dynamic or "pop out" sections. When the top menu is clicked the page will re-load and display the lower level in a diffrent colour.
Can this be achived with the Standard ASP:Menu control?
I am not a big fan of the pop out feature however I do not want all my options to be visible to my users at root
Hope that makes sense
Check out this basic ASP.Net Menu control page. You can click on the "Run" buttons to see very basic versions of the menus.
The advantage of using this particular approach is that you can tie it to a sitemap, so you don't have to keep updating the menu code. You just add the page(s) to the sitemap, and the menu picks it up.
You can also dynamically link the menu to different sitemaps, such as one for the admin menu and another for regular users' menu.
The Menu control is in the navigation section of the toolbox.
To experiment with the built-in functionality (before writing your own code to do what it will do for you), just drag and drop a menu control onto your form. Then, use the common tasks menu to:
autoformat -- good for quick & dirty because it sets hoverstyle too
set the data source
set the view type (static or dynamic)
define menu items with an editor
work with templates to set appearance
You have to go to properties to set menu appearance.

Resources