Magnolia CMS: property inheritance - magnolia

Using Magnolia CMS, I am trying to make a property inherit through all child pages.
The property gets set from a base page dialog.
Essentially its just a checkbox that toggles a show/hide Boolean that gets tested in the main page template (which child pages also use).
The dialog control component 'hideHeader' has this structure:
::hideHeader
.buttonLabel: Hide
.class: info.magnolia.ui.form.field.definition.CheckboxFieldDefinition;
.defaultValue: true;
.i18n: true;
.inheritable: true;
.label: hide;
.type: Boolean;
Which is added to the base page dialog.
I access the property in the template like:
[#assign hideHeader = false /]
[#if content.hideHeader?? && content.hideHeader?has_content ]
[#assign hideHeader = content.hideHeader /]
[/#if]
I cant get it to work in the child pages. It doesn't pick up on the set value from the dialog, just the default 'false' value.
What am I missing?

In order to inherit property from anywhere up in the hierarchy of pages, you need to use cmsfn.inheritProperty(content, "your-prop-name").
Using only stkfn.siteRoot(content) as suggested above, will return you root node of the site, so if value was overridden anywhere in the hierarchy you would not see that.
HTH,
Jan

so after suffering from 'code' blindness, I realised to implement the behaviour I wanted I needed to get the property using:
stkfn.siteRoot(content)
this now enables all sub pages to receive the parent pages properties.

Instead of all code above you can just use:
[#assign hideHeader = content.hideHeader!false]
To inherit property you have function in TemplatingFunctions
public Property inheritProperty(Node content, String relPath)
in freemarker you should do something like:
cmsfn.inheritProperty(content, "hideHeader ");

Related

ngx treeview dropdown

Can't bind to 'disabled' since it isn't a known property of 'ngx-dropdown-treeview?
ngxDisabledOnSelector property has not working in my case
my code here :
<ngx-dropdown-treeview [config]="config" [items]="items" [buttonClass]="buttonClass"
(selectedChange)="values = $event" [disabled]="!dropdownEnabled"
[ngxDisabledOnSelector]="'button.dropdown-toggle'" (filterChange)="onFilterChange($event)">
"disabled", is basically a HTML attribute, but not necessary an Input param for you ngx treeview, so, in this case you have 2 options.
1.- Use disable as angular html attribute
[attr.disabled]="!dropdownEnabled"
2.- Use direct attribute
disabled="{{!dropdownEnabled}}"
lets try

Override default style behavior of TinyMCE on new element

I was trying to search for a way to override default behavior of TinyMCE when it applies same styles to new elements. For example, when we apply some style to a paragraph and hit enter for new paragraph, it inherits same styles. Is it possible to override this behavior?
Yes, it is.
You will have to register the keyup event and check for the ENTER key.
Then you check the actual node the caret is in and you may add/remove classes or whatever. Use the setup tinymce configuration parameter to add the handler:
setup:function(ed){
ed.on("keyup", function(e){
if(e.keyCode == 13){ // ENTER
var node = ed.selection.getNode();
// do your magic here
}
});
}

Switching stylesheet URLs in Polymer.dart

I have a custom element that I'd like to be themeable. The link element that I put in my template, though, appears to be replaced by Polymer with a style element containing the contents of the URL (even in Dartium), which means I can neither bind the href attribute (which I hear doesn't work anyway) nor change it programatically on an event.
Actually, even without being able to switch it, I'd like to be able to set it once when the element is created, so I can create different instances of the element with different themes.
Is there a way to do this?
It turns out that you can programatically specify a stylesheet if you add a style element with a CSS import:
factory MyView(String themeUrl) {
MyView view = new Element.tag('my-view');
view.shadowRoot.append(new StyleElement()
..id = 'theme'
..appendText("#import url('$themeUrl');"));
return view;
}
I was able to switch it like this:
void switchTheme(String themeUrl) {
StyleElement theme = shadowRoot.getElementById('theme');
theme.replaceWith(new StyleElement()
..id = 'theme'
..appendText("#import url('$themeUrl');"));
}

Howto change style of <rich:simpleTogglePanel> dependent on attribute opened?

I would like to set the style of my dependent on the value of its "opened" attribute.
To be more specific: if the value of opened==false I would like to hide the simpleTogglePanel on printouts (i.e. setting style to display:none).
so something like this (pseudo code):
<rich:simpleTogglePanel opened="false" styleClass="#{ if opened then regular else hidePrint}" />
Is this possible? How? I'm using Richfaces 3.3.2.!
Use rendered attribute of your component.
<rich:simpleTogglePanel rendered=#{bean.boolean} />
EDIT
You should have a boolean property in your managed bean, so you will know if it's your togglePanel opened or not. So something like
#ManagedBean
#RequestScoped
public class Bean {
private boolean opened;
//setters and getters
}
then on your page change your togglePanel like this
<rich:simpleTogglePanel opened="#{bean.opened}" rendered="#{bean.opened}">
set the property in your bean to true or false depending on if you want to hide your togglePanel defaultly. Or you can hide it everytime when it's get toggled with Ajax, put this line inside the simpleTogglePanel tag
<p:ajax listener="#{bean.hidePanel}" update=":panel" />
set id of your panel to panel and add method hidePanel to your panel which just sets the boolean opened to false. Edit - it also should work without that listener

change id of a server control in asp.net

Hai guys,
I used find control to find a list item of an unoreder list inside a master page from content page using this,
Control home = this.Page.Master.FindControl("list").FindControl("home");
Now i have to change the id of the control home to "current" because to apply css for it....
Do you know the Type of the control you're finding? Neither Control nor ListItem expose a CssClass property, however, ListItem does expose it's Attributes property.
Update based on comment and other question:
You should be using System.Web.UI.HtmlControls.HtmlGenericControl
So something like this should work for you:
HtmlGenericControl home =
this.Page.Master.FindControl("list").FindControl("home")
as HtmlGenericControl;
string cssToApply = "active_navigation";
if (null != home) {
home.Attributes.Add("class", cssToApply);
}
If you think there might already be an class assigned to it that you need to append to you could do something like:
if (null != home) {
if (home.Attributes.ContainsKey("class")) {
if (!home.Attributes["class"].Contains(cssToApply)){
// If there's already a class attribute, and it doesn't already
// contain the class we want to add:
home.Attributes["class"] += " " + cssToApply;
}
}
else {
// Just add the new class
home.Attributes.Add("class", cssToApply);
}
}
If they aren't ListItems, cast them to the correct type, and modify the attributes collection as before, unless there's a CssClass property for that type.
Yes, to use css id's in asp.net is a big problem. first of all you can change your server control's id to what you want but, this will be regenerated by ASP.NET depending on the position of the control in your page's control tree.
My recommendation is to use cssclass property of the controls, and to replace the css ids to class.

Resources