Could someone please give some idea on how this can be done? This might be very simple and basics, but i couldn't figure this out.
Here is my requirement.
I have a category A with child keyword B and B got another Child Keyword C.
I want to get the exact path of selected keyword in my component template,Say for eg, if user selects keyword C, i need the value with path like A\B\C and not just as C. But Tridion always gives me the value as C and not as A\B\C . Component Schema is using "Tree" view to select the keywords.
Should I be writing dreamweaver custom functions to handle this? Or does tridion comes with some handler for this?
Any help would be highly appreciated. Thank you!
Thanks,
KK
As you just found out, the Tridion Keyword Hierarchy is "fake" - Keywords are stored as a flat list, not as a hierarchical list (like you would have with folders). The information about the parent and children keywords is stored in the keyword itself.
There are solutions for this - of course, for instance you can use this in a C# TBB:
Keyword keyword = new Keyword(new TcmUri("tcm:28-3368-1024"), session);
string hierarchy = keyword.Title;
bool done = false;
while(!done)
{
if (keyword.ParentKeywords.Count > 0)
{
foreach (Keyword k in keyword.ParentKeywords)
{
hierarchy = k.Title + " > " + hierarchy;
}
keyword = keyword.ParentKeywords[0];
}
else
done = true;
}
// Include Category
hierarchy = keyword.OrganizationalItem.Title + " > " + hierarchy;
EDIT: Updated to recursively "go up" the hierarchy. HOWEVER a keyword can have multiple parents, I'll leave that up to you to fix...
Keywords within a category are unique, so Tridion can safely refer to them by their name (and/or their TCM URI of course). And since a Keyword can have multiple parents, there may not be a single path leading from the root to your Keyword.
If in your situation the category can be represented as a tree, you can of course build a single path to each keyword. In that case you'll need some (C#) code that walks up the parents axis and concatenates the names. You can put this code either:
in a TBB that you put into your template before the DWT OR
in a custom Dreamweaver function.
Either way will work fine.
Related
Lets say I go to - https://www.expedia.co.uk/
I go to Trains Tab and do a search for any date with 1 passenger selected.
You'll be on next page where to select trains from a list, now if I want to click on any ShowFares button its not being recognized uniquely by CSS= .btn-secondary.btn-action (its returning more than one matching node. So couldn't use it.
while using xpath -
.//*[#id='ember968']/div/div[1]/div[2]/div[2]/div/button
I see its recording #id with some emberxxx which again is not unique as its getting changed for every other search list..
Similarly when I clicked on ShowFare then unable to pick a train or fare as same above problem occurring as CSS is returning several nodes and xpath has this emberxxx which is not unique.
As with the same attributes, we have more than one element we are not able to pick right one. I tried with jquery selector .btn-secondary.btn-action:eq(1) and it is working. By using above selector you will pick first Show Fares button every time Let me know if you have any queries.
CSS Selector: .flex-1up.flex-listing.flex-theme-light li:nth-child(1) button
Use, for example, xpath-function starts-with:
(//*[starts-with(#id, 'ember')])[2]
This function find part of name. And then you can use filtr by [] to find needed element by index.
I see there are lot other elements having same xpath. Here is my suggestion if you want to click on first element.
//button[#class='btn-secondary btn-action']/span - push that to list, loop through list and use getText(). If matches 'Show Fares', click on that.
List<WebElement> buttonList = driver.findElements(By.xpath("//button[#class='btn-secondary btn-action']/span"));
for(int i=0; i<=buttonList.size() ; i++){
WebElement ele = buttonList.get(i);
if(ele.getText().contains("Show Fares"){
ele.click();
}
}
I am using Query builder as below to get the list of distinct pages which uses the component (component name will passed as a parameter) in property. I need to pass two parameters, cq:lastReplicationAction=Activate and sling:resourceType=component path. I tried above JSON query but no result and it is failing since the component may be used at any level of page node. E.g, /jcr:content/par/component or /jcr:content/par/mainpar/component
https://host:port/bin/querybuilder.json?1_property=sling:resourceType&1_property.value=COMPONENTPATH&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=FROM_WHICH_CONTENT_PATH&type=cq:Page&p.limit=-1
Components are placed under par node of page, and Replication property is part of page JCR node. That's the reason your query is returning 0 result. Try this query:
http://localhost:4502/bin/querybuilder.json?1_property=jcr:content/par/*/sling:resourceType&1_property.value=<Component-Path>&2_property=jcr:content/cq:lastReplicationAction&2_property.value=Activate&path=<BASE-Content-Path>&type=cq:Page&p.limit=-1
I have used following property to find component: jcr:content/par/*/sling:resourceType If your par node has different name then use correct name of par node.
A xpath query can be used to get the pages where a components used.
Goto CRXDELight using http://AEM-AUTHOR-HOST/crx/de/index.jsp, open Tools -> Query. Place the query into the Query box:
/jcr:root/content//*[jcr:contains(#sling:resourceType, 'COMPONENT_NAME/PATH')] order by #jcr:score
if you know exact path of the component then use below query.
/jcr:root/content//*[#sling:resourceType = 'COMPONENT_PATH'] order by #jcr:score
It will return list of paths of content nodes where your component being used. You may split the each path before /jcr:content to get exact page paths.
I am trying to add a new premake5 field in my premake5 script but am having trouble understanding how to specify the field.kind .
I want to add a field that contains a list of (path, string ) pairs but can't work out how to specify the kind spec .
The documentation and examples are not particularly clear.
This is how I have registered my new field
premake.api.register( {
name = "mypathmappings",
scope = "config",
kind = "list:path:string", or "list:keyed:path:string"
}
)
and inside of a config scope I declare the field item like so
project myproject
mypathmappings { ["path/to/file1"] = "stringvalue1", ["path/to/file2"] = "stringvalue2"}
However when it comes to processing time I don't get what I'm expecting in the field:
function processpathmappings(cfg)
local pathmappings = cfg.mypathmappings
for path, value in pairs(pathmappings) do
--do something with the path and value but
--value is not a string as expected
end
end
Can someone explain how the complex kinds can be built up correctly from the field kinds registered in api.lua?
I get that "list:integer" specifies a list of integers but don't know how the "keyed" element works for example.
Right now, it is not possible to control the "kind" of the keys in a keyed value. The best you will be able to get with the current system is kind="keyed:string", which should give you the values (the strings) that you want, but the paths will not be processed by Premake (made absolute, etc.)
If it is feasible, you might want to flip it around to kind="keyed:path" and set the values like this:
mypathmappings { ["stringvalue1"] = "path/to/file1" }
But that relies on your string values being unique within a map.
In theory, Premake's field API could be extended to support kinds of keys; feel free to open a ticket or submit a pull request.
I am trying to extract requirements from QC Requirement module. i could extract all requirements of a QC project but i would like to extract selected requirements only. So i need to give folder path and extract requirements accordingly.
Currently i use ReqFactory to extract Reqs from QC. Could you please help me or give me idea to extract requirmeents from selected folder path.
I tried Req Path and father id, but still it does not fulfill my need as some may have multiple sub folders under parent folders.
I assume you like to get all the child requirements of a requirement using the OTA API? The only solution I can offer is a bit clumsy. First you have to get the requirement where you want to start, e.g. "Requirements\Projects\ProjectX". How to achieve that is described in the OTA API Reference as an example of the ReqFactory object ("Find a specified requirement in a specified folder"). Or it is posted in this forum. If you know the ID of the start-requirement you can simply get the requirement with req_factory.Item(id).
When you have your requirement where you want to start, you can use the Find-method of the ReqFactory to get all its children, resp. all Requirement objects starting with the same path as the start-requirement. Here is an example-method in Ruby:
def list_all_child_requirements(start_req)
req_factory = #tdc.ReqFactory
req_path_strange_format = start_req.Field("RQ_REQ_PATH")
child_req_list = req_factory.Find(start_req.ID, "RQ_REQ_PATH", req_path_strange_format, 8)
child_req_list.each do |list_req|
puts list_req
end
end
The req_path_strange_format contains a String in the strange Quality Center notation like "AAAAAB". The Find-method starts from the start-requirement and searches all requirements which path starts with the same path as the path of the start-requirement. The parameter 8 means "starts with pattern" (described in the API Reference, Enum tagTDAPI_REQMODE). I just don't know how to access the Enum using Ruby, thats why the magic 8 is used... The Find-method returns a list with format "ID,NAME". From there it should be no problem to extract the requirements.
Doing the same directly in QC with a VAPI-XP-TEST and VB looks like that:
TDOutput.Clear
Dim reqPathStrangeFormat
Set reqF = tdConnection.ReqFactory
Set startReq = reqF.Item(14) ' ID of parent requirement
reqPathStrangeFormat = startReq.Field("RQ_REQ_PATH")
TDOutput.Print reqPathStrangeFormat
Set childReqList = reqF.Find(startReq.ID, "RQ_REQ_PATH", reqPathStrangeFormat, TDREQMODE_FIND_START_WITH)
For Each childReq in childReqList
TDOutput.Print childReq
Next
This code first prints some strange string "AAAAAB" or something similiar, then a list with "ID,NAME" of the requirements.
I have a web app and two objects with same class name (no IDs), other attributes also the same. The difference only in same style attributes: one of the objects has "style.display='block'", other has "style.display='none'". (could be other styles attributes!)
How I can identify first object by it's style attributes? For thing such names, I could use "attribute/name", but is there anything like this for style?
Thank you!
Edit: My original answer was true for its time but UFT has since added support for style/ properties. You can now use style/display:=none".
This is indeed a limitation in QTP :(
One thing you can do is write a small WebExtesibility project which adds the display property to your test object.
I know this is an old question, but it is accepted as if there is not a simple solution for it, while there is:
Yes you can, but it has to be an attribute on the actual object and not inherited by parent objects (well, I had negative results on that situation).
' Make a new description for the object
Set desc = Description.Create()
desc("micclass").Value = "WebButton" ' assuming webbutton here
desc("Class Name").Value = "YourClassName"
' This returns a collection with buttons matching your description
Set Btns = Browser("YourBrowser").Page("YourPage").ChildObjects(desc)
For BtnIndex = 0 to Btns.Count - 1
' This will show you the display style, so you can make a selector here
MsgBox "Button " & BtnIndex & " has display style: " & Btns(BtnIndex).Object.currentStyle.Display
Next