How to check if node exist by path in XSLT Options
chimnit
Posted: Friday, December 28, 2007 8:42:29 PM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi everybody,

First of all Merry Christmas to you all :o)

I am trying to create a site with different languages, where the structure is almost identical under every language. E.g. a page in english may be: www.domain.dk/en/test/home.aspx and in danish: www.domain.dk/da/test/home.aspx.

The thing is that I'm trying to create a language selector in XSLT, that can change to the same page, but in another language, when clicking the language link. But as the users tend to forget naming conventions, I want to build in a default page, so that the user is redirected to the frontpage of the selected language, if the page does not exist.

So my question is whether there is a method in the umbraco library that can be accessed from XSLT, that returns true or false when called with a given URL as an argument????

I hope my question is understandable.

Thank you very much in advance :o)

All the best to you all,

Kim
drobar
Posted: Friday, December 28, 2007 8:58:57 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
There are a couple ways you could approach this. One is to just redirect the user to the other language page and assume it will be there. If it isn't there then you can redirect to the home page using the various 'not found' handlers in umbraco. (See Per's excellent Not Found Handlers umbraco book)

Alternatively, you could use the umbraco.library:GetXmlDocumentByUrl() call in your xslt and check to see if it has content or not.

Or use the umbraco.library:GetXmlNodeByXpath() call in your xslt to find the corresponding node in the alternate language and either go to that page or the homepage depending on the result.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
chimnit
Posted: Wednesday, January 02, 2008 12:42:57 AM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi Doug,

Thanks a lot for the quick answer. I'll try your solutions and see which one I can get to work best :o)

BTW, is there an easy way to find the adress of the current page in the XSLT???

All the best in 2008

Kim
drobar
Posted: Wednesday, January 02, 2008 3:04:12 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
In XSLT for umbraco there is a $currentPage parameter, which is the (surprise!) current page. Starting with this you can get the @id for the current page ( $currentPage/@id ) or its node name ( $currentPage/@nodeName ) or its friendly url ( umbraco.library:NiceUrl($currentPage/@id) ), etc.

The umbraco.library has a number of very useful functions such as NiceUrl() and NiceUrlFullPath() and a bunch of others. The easiest way to insert them into your XSLT is to click the "Insert xsl:value-of" icon in the toolbar; click the "Get Extension" button; select "umbraco.library" from the list of libraries, and then you'll see a list of available functions.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
chimnit
Posted: Wednesday, January 02, 2008 4:17:22 PM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi Doug,

Once again thank you very much for your answer. I'll try to see if I can make it work... all the best and happy new year...

Kim
azzlack
Posted: Tuesday, March 04, 2008 2:23:04 PM

Rank: Devotee

Joined: 8/5/2007
Posts: 94
Location: Bergen, Norway
What can you do when the nodename of the pages differ depending on the language you are using?

I have also been trying to make a language selector page using usercontrols, but I think XSLT might be the easiest way to go...

www.eyecatch.no
azzlack
Posted: Wednesday, September 24, 2008 12:45:53 PM

Rank: Devotee

Joined: 8/5/2007
Posts: 94
Location: Bergen, Norway
After gaining some more knowledge about umbraco, i have learned that trying to have a 1:1 multilinguage site with unequal nodeNames is virtually impossible.
There is a tutorial for how to do a 1:1 site on the umbraco page.
Otherwise, having different sites for different languages is (in my opinion) the best solution.

www.eyecatch.no
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.