I have an alert section pulling items with a repeater. My transformation pulls date and copy and displays them in UL tags.
I've been asked to make a change where a specific alert would only be seen by people is a specific group/role.
My thoughts were change the page type form with a check box. On the transformation side i would then need a conditional statement where the check box is true and the user is part of specific Role.
My transformation is currently an ASCX and is as follows:
<li><%# Eval("Alert") %></li>
I imagine it being something like this
<% if ( checked = true && role = XX ) { <li>Eval("Alert")</li> } %>
I just can't figure out the conditional statement.
For Text/XML transformation
{% if(checked == true && CurrentUser.IsInRole("MyRole")) {return "<li>" + Alert + "</li>"} %}
ASCX
<%# If(CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName) && Eval("checked") == true, "<li>" + Eval("Alert") + "</li>","") %>
I'd recommend to add some CSS class based on your condition:
<li class="<% if(Eval<bool>("FieldsName") &&
CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName);) {"alert"} %>">
....
</li>
Having "alert" class added to your li, you can change visibility, colors or whatever you need for that item.
This approach requires ASPX transformation.
You can use the method CurrentUser.IsInRole(, )
I came up with something like:
<%# (checked && CurrentUser.IsInRole("_everyone_", "corporate") ? Eval("DocumentName") : "empty") %>
David
Related
How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.
This is a piece of HTML from which I'd like to extract information from:
<li>
<p><strong class="more-details-section-header">Provenance</strong></p>
<p>Galerie Max Hetzler, Berlin<br>Acquired from the above by the present owner</p>
</li>
I'd like to have an xpath expression which extracts the content of the 2nd <p> ... </p> depending if there's a sibling before with <p> ... Provenance ... </p>
This is to where I got so far:
if "Provenance" in response.xpath('//strong[#class="more-details-section-header"]/text()').extract():
print("provenance = yes")
But how do I get to Galerie Max Hetzler, Berlin<br>Acquired from the above by the present owner ?
I tried
if "Provenance" in response.xpath('//strong[#class="more-details-section-header"]/text()').extract():
print("provenance = yes ", response.xpath('//strong[#class="more-details-section-header"]/following-sibling::p').extract())
But am getting []
You should use
//p[preceding-sibling::p[1]/strong='Provenance']/text()
I have a transformation, used with a repeater, for a slider. All is working well. I have a slide caption, that isn't required. What I'm struggling with is a conditional statement where the caption tag doesn't show.
Here's my transformation:
<section class="imageSlide">
<figure role="group">
<img src="{% SlideImage %}" alt="{% SlideAlt %}">
<figcaption><p>{% SlideCaption %}</p></figcaption>
</figure>
</section>
What I'm hoping to do is not render the figcaption if there is no SlideCaption. SlideCaption isn't a required item. I had though if using jquery to change the display type of the <p></p> tags were empty, but want to avoid a lot of DOM manipulation.
I know that the syntax is something like this, but I haven't found a good example I can use as a base solution.
{% if(....) %}
Something like this should work. Didn't test it, so may need some tweaks.
{% IfEmpty(SlideCaption, "","<figcaption><p>" + SlideCaption + "</p></figcaption> ") %}
Another example for future reference if you dont want to be limited to using IfEmpty
{% if(SlideCaption != "" && SlideCaption != null) { return "<figcaption><p>" + SlideCaption + "</p></figcaption>" } %}
I'm try to implement test automation with watir-webdriver. By the way I am a freshman with watir-webdriver, ruby and co.
All our HTML-entities have a unique HTML-property named "wicketpath". It is possible to access the element with "name", "id" a.s.o, but not with the property "wicketpath". So I tried it with XPATH but I have no success.
Can anybody help me with a codesnippet how I can access the element via the propertie "wicketpath"?
Thanks in advance.
R.
You should be able to use xpath.
For example, consider the following HTML
<ul class="ui-autocomplete" role="listbox">
<li class="ui-menu-item" role="menuitem" wicketpath="false">Value 1</li>
<li class="ui-menu-item" role="menuitem" wicketpath="false">Value 2</li>
<li class="ui-menu-item" role="menuitem" wicketpath="true">Value 3</li>
</ul>
The following xpath will give the text of the li that has wicketpath = true:
puts browser.li(:xpath, "//li[#wicketpath='true']").text
#=>Value 3
Update - Alternative solution - Adding To Locators:
If you use a lot of wicketpath, you could add it to the locators.
After you require watir-webdriver, add this:
# This allows using :wicketpath in locators
Watir::HTMLElement.attributes << :wicketpath
# This allows accessing the wicketpath attribute
class Watir::Element
attribute(String, :wicketpath, 'wicketpath')
end
This will let you use 'wicketpath' as a locator:
p browser.li(:wicketpath, 'true').text
#=> "Value 3"
p browser.li(:text, 'Value 3').wicketpath
#=> true
Try this
puts browser.li(:css, ".ui-autocomplete > .ui-menu-item[wicketpath='true']").text
Please Let me know is the above scripting is working or not.
I need ideas on how to go about table layout problem.
I want to set different width of the columns dependent on the picked language.
You can have language specific CSS, and then simply load the appropriate CSS based on language.
In the CSS you can add styles to your table for defining the layout.
A variable switch, such as:
<%
dim columnWidth
if session("lang") = "eng" then
columnWidth = 50
else
columnWidth = 100
end if
%>
<table>
<tr>
<td width="<%= columnWidth %>px">[content]</td>
</tr>
</table>
For c#, the code would be:
<%
private int columnWidth;
if (session("lang") == "eng") {
columnWidth = 50;
} else {
columnWidth = 100;
}
%>
Use if-else inside scriplet based on the currently selected language and place appropriate "td" tags.
Hope this is what you are looking for !