Umbraco 7.5.1 umbracoNaviHide - umbraco

To be able to filter out items that should not be rendered with .Where("Visible") I need a property called umbracoNaviHide that returns true or false.
In earlier versions this was added to the Generic tab. However now you cant append to that tab anymore.
How would I accomplish hiding pages now?
Here's my foreach:
#foreach (var Area in Model.Content.Children.Where("Visible"))
{
Here's a statement about it. But I cant find any workaround.
Related Changes Summary - 7.4 beta - Option toCannot add properties to the "Generic properties" tab
Description - In the 7.4 beta it's not possible anymore to add
properties to the "Generic properties" tab. I know this has been done
because properties can be a bit hidden on that tab and usually are
better on a separate tab. But there are situations where the
properties are better on that tab.

You can add that property as a true/false datatype to any tab. However, it's important to note that umbracoNaviHide does not do anything special it is just a magic string, that, when implemented as a true/false datatype, it works with
.Where("Visible").
Personally I don't use it anymore. If I need to cause items to be visible or not then I would name the property more specifically. For example, it is often useful when implementing menus where you want some nodes to be visible but not others. I generally have a Menu tab where one of the properties is a true/false type called Show in menu with an alias of showInMenu.
In code it could be something like below (I have used TypedContentAtXPath to get the parent node of a specific doc type. Of course there are various ways of doing this)
var homeNode = Umbraco.TypedContentAtXPath("//MyHomePageDocType").First();
var menuItems = homeNode.Children.Where(item=>item.GetPropertyValue<bool>("showInMenu"));
foreach(var item in menuItems)
{
// Do your menu stuff here
}
Hope that helps
J

You can create a composition for node visibility with a checkbox to show or hide the menu item. And you can inherit this to the doc types that you do not want to show.
And then you can do
_homeNode.Children.Where(x => !x.GetPropertyValue<bool>("hideInNavigation"));
Hope this helps!

Related

paper-menu with multiple selections, howto deselect all

I use paper-menu with multiple selections (multi). Everything works fine so fare, but with a deselect all method things seems more complicated.
With html
<paper-menu multi selected-values="{{selectedValues}}">...
Dart
#property
List<String> selectedValues = [];...
Things got binded, and every iron-select/iron-deselect event results in a correct update of the selectedValues list in dart.
With clear('selectedValues') the list empties and the logic behaves like no selection is done, but in Dartium the items that previous was
selected remains marked as selected.
I have also tried with the selectedItems List or with the foreach deselect with the select method to PaperMenu, but still not successful update
in Dartium.
Anyone with ideas how to implement this?
Found a workaround for the issue with the select method. The menu with selected values can be replaced with a new similar element created with the Dom api. One drawback is the bindings can't be set up, so these needs to be hacked with get and set methods at the element. Otherwise this seems to work ok. The calls to the Dom api are shown below.
ParticipantMenu oldPm = $$('#id_filterselection') as ParticipantMenu;
ParticipantMenu newPm = document.createElement('participant-menu');
Polymer.dom(parentNode).insertBefore(newPm, oldPm);
Polymer.dom(parentNode).removeChild(oldPm);
PolymerDom.flush();

how to track the social media icons using DTM (Dynamic tag manager)

I have the below code in my web site.
I want to track each anchor tag using DTM. I know how to track single element. Since here we have a bunch of different elements, can anyone help how to track them using DTM? I don't want to create separate rule for each element. In a single rule how can we track these elements.
Here is an example of what you can do.
For Element Tag or Selector put "a.at-share-btn" (no quotes). This will target all the relevant links first. We can look for this too in the next step, but "pre-qualifying" it with this will improve performance so that the rule is not evaluated against every single a click.
Then, under Rule Conditions, add a Criteria of type Data > Custom.
In the Custom box, add the following:
var shareType = this.getAttribute('class').match(/\bat-svc-([a-z_-]+)/i);
if (shareType&&shareType[1]) {
_satellite.setVar('shareType',shareType[1]);
return true;
}
return false;
This code looks for the class (e.g. "at-svc-facebook") and puts the last part of it (e.g. "facebook") into a data element named shareType.
Then, you can reference it using %shareType% in any of the DTM fields. Note: because this data element is made on-the-fly, it will not show up in the auto-complete when you type it out in a field.
Alternatively, in custom code boxes (e.g. if you are needing to reference it in a javascript/3rd party tag box), you can use _satellite.getVar('shareType')

How to localize selectOptions on the visual force page

I am trying to localize selectOptions on the Visual Force page.
Here is the .class code snippet:
List<SelectOption> options = new List<SelectOption>();
List<MyOption__c> dropDownValues = [SELECT Id, Display_Label_Name__c FROM MyOption__c];
for (MyOption__c val : dropDownValues) {
// Display_Label_Name__c field is the label from *.labels that needs to be translated
options.add(new SelectOption(val.Id, val.Display_Label_Name__c));
}
Here is the .page code snippet:
<apex:selectList value="{!myVal}">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
Right now the dropdown displays the Display_Label_Name__c verbose. I am trying to see how I can display the translated version from the .labels file. Is it possible? If not, what's the work around?
Thank you for your responses!
All localisation of page text can be done with Custom Labels.
Enable the translation workbench with the languages you require.
Create labels for all the localisible text on the page.
Replace the page text with the labels.
Add a translation for each label.
Change your profile langauge to test.
But for your case you pull the select option text from a custom object. If the values of the select list are not expected to change frequently, less than once a week or so, then I would change to using custom labels.
Otherwise, you lose the value of Salesforce automatic language selection and have to implement something yourself.
I would recommend extending the custom object MyOption__c to have columns for all the supported languages. You could use an if/else block or dynamic apex to select the select option text.
Sample using Dynamic Apex
string language = ParseForSupportedLangauges(UserInfo.getLanguage()); // includes __c
list<sobject> dropDownValues = Database.query('SELECT Id, '+language+' FROM MyOption__c');
for (sobject val : dropDownValues) {
options.add(new SelectOption(val.get('Id'), val.get(language)));
}
ParseForSupportedLangauges() would be a custom method that checks for supported languages and assigns the default when necessary.
EDIT
Turns out there is a solution: Don't look for something until you need it, right?
Introduced in Spring '12 is the ability dynamicaly select the label to display suing array syntax. Also, the ability to create visualforce components from the controller was added but using the array syntax would be sufficient for your problem. This method would allow you to select the labels you want by using the query results from MyOption__c.
Using a repeat in visualforce to loop over the query results
<apex:repeat value="{!displayResultsValues}" var="labelName">
<apex:outputText value="{!$Label[labelName]}"/>
</apex:repeat>
Here is a good article to show the usage and syntax.

Select Multiple, get selected values and non-selected values

I have a select multiple on my page. The user can add elements to the list and remove them selecting one or more.
When I get the select's value through params.selectName, I receive only the selected ones. I
understand that this is the default behavior, but I need all of them, not only selected elements.
I don't really want to select all elements each time I send data to server. Does anyone have a better solution? Thanks.
The approach taken by the <g:checkBox> tag is to create a hidden field with the same name as the checkbox but with an underscore prepended. You could use a similar trick here, i.e. whenever you add a new <option> to the <select> you also add a hidden field named (say) selectName_options with the same value. Then in the controller you can take the difference between params.list('selectName') and params.list('selectName_options') to get the un-selected options from the list.
This is a bit of a complex solution to what should be a simple problem, but in my current project we just had the same problem and solved it as #cdeszaq describes.
Assuming an object of class Foo with a collection (bars) of Bar items, where each Bar has a String name and outputs it as its toString() representation, we do this in the FooController:
def removedItems = fooInstance.bars.findAll {
!params.bars.collect { it.key }.contains(it.name)
}
if(removedItems){
removedItems.each {
fooInstance.removeFromBars(it)
}
}

Wix: ListBox value limitation

Value field in ListBox table has String[64] type. Is there posible to expand this 64-characters limitation? I need to store some directory pathes there.
It's probably (never tried) possible in WiX to override the default schema of he ListBox table. I know in InstallShield I just go to the direct editor and adjust it. WiX has a template schema that is used to build the MSI and you might be able to use the Table element to redefine it. Or it might just give you an error message saying you are defining a well known table.
However, I'm not sure if there would be any side effects in the ListBox control if you exceed 64 char. I don't see anything in the MSI SDK saying what's allowed so I guess your milage may vary.
Here's a trick that you might like though. It's called the evil twin dialog trick. See, in MSI there's a bug that UI elements don't refresh very well and this trick works around it. Consider this:
Dialog1 with ListBox associated to property TESTPROP and Items One value 1 and Two value 2.
Textlabel that displayes [TESTPROP].
When start the dialog the text label is empty after clicking a row in the listbox. Click back and next and suddenly it has the expected text of 1 and 2.
Now create a clone of this dialog ( Dialog2 ) and put a control event on the Listbox of dialog1 that says NewDialog Dialog2 condition=1 and put a control event on the Listbox of dialog2 that says NewDialog Dialog1 condition = 1
Now when you run it the screen refreshes ( although with a big of an ugly flicker ) See it looks like it's the same dialog only it's really the evil twin dialog that's being transitioned to so that the data refreshes correctly.
Now for extra credit use your custom actions to do something like this
ListBox Item 1 Text C:\Pro...Foo\Bob value LISTBOXDIRPROP1
ListBox Item 2 Text C:\Pro...Foo\Ed value LISTBOXDIRPROP2
Property LISTBOXDIRPROP1 = C:\Program Files\Foo\Bob
Property LISTBOXDIRPROP2 = C:\Program Files\Foo\Ed
Then set your TextLabel to display [[TESTPROP]]. This tells it to get deference the value of the value of the property. In other words, TESTPRO = LISTBOXDIRPROP1 = C:\Proggram Files\Foo\Bob
This trick would allow you to display a line that fits the 64 char constraint yet gives additional information when the user selects it.

Resources