Kentico: Can i get Page Title via nodeID? - macros

I would like to display a list of a couple of my pages in a list.
Is there a macro or something else to get the page title of another site then the actual one?
All i need is a little smart function that can give me the name of a page.
Thanks for your help.

If you have the nodeID of the page you want the title of, you can use the TreeHelper static functions.
TreeNode yourNode = TreeHelper.SelectSingleNode(nodeID);
then easily enough access the name from there.
yourNode.DocumentName;
Note the difference between a TreeNode and a Document is that there are possibly multiple Document's for one TreeNode, where each is a different language/culture.

Related

Is it possible to have different styles in one element in Jaspersoft?

Let's say I need to print the full name of a person. What I originally did was to separate the first name and last name into two elements and placed them side by side since they needed different styling (this is just an example):
Lastname, Firstname
However, I found out after that I can't actually make their width dynamic because the developers made an effort not to allow it. So now I'm wondering if I can present the name with two different styles inside one element. Is this possible? How would I accomplish that? I hope you can help, thanks!
Okay so apparently you can. All you need to do is setup the markup attribute on the text field.
Refer here for more details: http://jasperreports.sourceforge.net/sample.reference/markup/

How can I get data from MediaWiki API if the title doesn't exactly match?

I am trying to get some information from different Wikipedia pages but in the MediaWiki result I don't get the data from the page if the title I use in my query doesn't exactly match the title of the page. Is there any way to get the best match for this title? Maybe something like the SQL LIKE operator?
Here is one example. With titles="Sankt-Jacobikirche" I don't get the page I'm looking for.
http://nl.wikipedia.org/w/api.php?action=query&prop=extracts|info&titles=Sankt-Jacobikirche&exintro=1&inprop=url
Sometimes at least I get the correct title so I can do a new request and get the correct page like with titles="Sankt-Jacobikirche_(Hamburg)"
http://nl.wikipedia.org/w/api.php?action=query&prop=extracts|info&titles=Sankt-Jacobikirche_(Hamburg)&exintro=1&inprop=url
And get the correct page with the title I get in the REDIRECT or Normalized section, like it happens with the correct title: titles="Sint-Jacobikerk (Hamburg)"
How can I get this final data starting from titles="Sankt-Jacobikirche" ?
You didn't say what you're trying to achieve, but as svick says guessing the title is an exception, not the rule.
You need to first get the correct title either by title search API or by full text search API.

How do I get Zend_Navigation to work with database defined data?

I've got a Zend_Navigation component I use to display breadcrumbs on a page. It currently says something like:
"Companies > Edit a Company"
when displaying the edit form. I would like to make it say something like
"Companies > Editing FooBar"
What's the best way to accomplish that?
I had the problem that I wanted to show breadcrumbs even when the parent is set to not visible. Drove me nuts until I found the reason. Your problem is not much different, I think.
I have a unique ID set with basically all links; hence, I can fetch all nodes like the following:
// in view scripts
$navObject = $this->navigation()->findOneById($id);
// now you can manipulate the object however you like
$navObject->setLabel('Editing FooBar');
You can find the node by other means, there is findOneBy() method where you have to pass the target object.
Once I printed the breadcrumbs I had to reset setVisible(false) to the old value, though. Depending on your needs you might have to reset the label, too.

Need to print out all links on a sidebar in selenium (xpath?)

I need to find any extra links and print them out. I started by doing:
get_xpath_count('//li/a')
and comparing it to the size of an array that holds the name of all the links for the sidebar. When the count is too high/low, I need to print out all the extra/missing links. I would like to make a list of the names so I can compare it to the array. I've tried a few things like get_text('//li/a'), which returns the name of the first. get_text('//li/a[1]) does the same, but any other index returns nothing.
Any ideas? Also, I need the name that's displayed on the link, not the actual href.
Edit* Also, i'm pretty new to selenium and Xpath. Please let me know if there's info I let out that is needed, or just any suggestions towards thew way I'm going about this.
I have been able to get this to work using CSS element locators. Since I use CSS selectors far more often than Xpath, I find it easier to always use them with Selenium as well.
$selenium->get_text("css=li a:nth-child(1)")
$selenium->get_text("css=li a:nth-child(2)")
$selenium->get_text("css=li a:nth-child(...)")
$selenium->get_text("css=li a:nth-child(n)")
Use:
(//li/a)[$someNumber]
this will get you the text of $someNumber-th //li/a in the XML document.
In order to know what values to use to substitute the $someNumber with, you need to know the total count of these elements:
count(//li/a)
This is in JAVA. You can use the same concept in perl
int totCountInPage=selenium.getXpathCount(//li/a);
for(int count=1;count<=totCountInPage;count++)
System.out.println(selenium.getText("xpath=//li[count]/a"));
This should print text inside the anchor links under all li tag.

Get form field value via module [VBA]

I have a program built with VBA, in access.
I have a form with the field chDate and I need to get the value of the field in a module file named Global (not class module).
I tried to access it but I think I get empty value, string. not error.
I'm no expert with VBA, its new to me (I have experience with VBS).
Can someone please help me and tell me how can I access the value of a form field via module file?
Thanks!
If you can provide some sample code, it might help us in trying to get you a solution.
Here's what might work:
Dim an object as an instance of your form, and set the instance to a new instance. These two lines will do that (assuming the form is called frmForm)
Dim theForm as frmForm
Set theForm = new frmForm
then Show that Form:
theForm.show
The form will get the focus, so you can populate the fields. At that point, once the form is hidden, your code should be able to pull the field as such:
var1 = theForm.txtFormField.Text
However, if you unload the form in code, all variables directly tied to the form will be lost. In that case, you might want to follow Oneide's example, and set a global variable to the value of the form field. You can do this in one of the form's event handlers.
Let me see if I can recall my Access days. In your global module you should access the form field be prefixing the form name i.e.
var1 = Form1.txtFirmField.Text
As far as I know, you're trying to get the data the wrong way.
Anytime you would try to get your form data, from a standard module, your form probably will already be closed or, if you're not opening it as a restricted window, the value will not be ready yet.
Anyway, if you could get pass through all the difficulties above, you're probably coding in a not standard / right way.
Remember that VBA is an event driven language, and you would be better using it's strenghts rather than fighting against them.
As a final word, if this is just a casual coding, I suggest you using a global variable and make de Code Behind Form have set it up on control's change event.
If you're not sure what I mean, please leave a comment and I'll try to explain it better.
And, if you don't mind, let us know more about your starting code to get better answers.