Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Getting The URL Of a Document View modes: 
User avatar
Member
Member
Jason - 3/26/2011 3:13:29 PM
   
Getting The URL Of a Document
Hi all,
In my Custom Hotel Document I have created a field called HotelURL
I want this to default to the documents URL so for example the user creates a new hotel called "jasons Palace"
and would like the url: http://www.mysite.com/hotels/jasons Palace.aspx
saved in to the Custom Hotel Documents HotelURL Field.

Actually I don't need the "http://www.mysite.com/" Part but I do need the documents url

I need this because I am linking data with this hotel (prices) from another database so when I go through the pricing stuff I will need the path to the Hotel so that the prices can link to the Hotel. Having the URL in the custom Documents Database Table means I can easily look it up when I am querying the external data.

How can I achieve this please? Is there a macro I put into the form the user uses to create the hotel?

Thank you for any help

Jason

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 3/28/2011 4:18:19 AM
   
RE:Getting The URL Of a Document
Hello,

For this you can create a custom form control. You can check the input field of the document name and fill the URL according to it. Or you can leave the field blank during the creation and fill it during the data insertion in a custom handler.

Best regards,
Boris Pocatko

User avatar
Member
Member
Jason - 3/28/2011 6:31:20 AM
   
RE:Getting The URL Of a Document
Hi Borisp,
I would go with a Custom Handler as I have already created one, for other things.
What would I be looking to use?
DocumentURL? I mean what would I call to do that?
Thanks

User avatar
Certified Developer v7
Certified  Developer v7
Bram (bdbweb) - 3/28/2011 8:42:38 AM
   
RE:Getting The URL Of a Document
Hi Jason,

If I understood correctly, you want to store the live url of a page in a form field (defined in the doctype of the page). You can do this by using the treenode event handler, or if you use workflows, the workflow event handler.

You can create a method that adds the live url for the page in the designated field in the doctype. Then call that method in the OnAfterInsert (treenode) or OnBeforePublish (workflow).

Getting the page url can be done with
TreeNode currentDoc = (TreeNode)treeNodeObj;
string docLiveUrl = functions.GetUrl(currentDoc.NodeAliasPath)


I don't know for sure if the Functions namespace works in the custom event handlers, but you can try.

Hope this may help.

Best regards,
Bram

User avatar
Member
Member
Jason - 3/28/2011 6:01:35 PM
   
RE:Getting The URL Of a Document
Hi all,
thank you all for the replies, I will try it out later.

I just want to clarify what I am doing.

The website I am building is a Holiday company (Tour operator)
There are 2 parts to this website
1. The content (Hotel Info/images/country-resort info / maps etc) and is the shop window to marketing offers etc
2. Pricing and booking data.

The pricing system sits on another server and has its own Company made (I made it) CMS to enter and deal with CRUD operations on prices and business rules. It also feeds data to 3rd parties etc and is secured with the only way to get data is via a web service which is read only, the server does not accept or allow tcpip connections to the SQL server and only access is via a secured site for data entry etc.

Kentico will be used to manage product content display data from the pricing system, market special offers etc.

The problem is that the Hotels exist in both databases, but with different ID's
So part of the custom Hotel document in kentico is a field that is labeled "LinkedPricingHotelID" the user will input the hotelID into the form when creating a new hotel. Business rules within the company dictate that any new hotel in the pricing system must first be put on the pricing system and then on the website, this has been the rule since the company used the web.

Now you might think asking the user to do this is crazy, but its fine and all the users know the codes anyway, and they are easy to remember so that's fine.

This allows me to have a link between a Kentico Hotel Document and its pricing. I can then retrieve this value (LinkedPricingHotelID) on the Kentico Hotel page and then query and display pricing data and availability in a user control in the Hotel-Page Transform from the pricing system. This is all working and I am happy.

The reason for me to also save the Hotel Document or Page URL is when I need to show Special offers. Special offers come from the pricing system, but contain no Hotel content or info as this does not exist in the pricing system because that is just that a pricing system. But the offer will have the hotelID in it from the Pricing system, so using that I can then say pusedo code:
Select <my table> From Custom_Hotel_Document table
Where LinkedPricingHotelID = hotelID (this would be the hotelid from the pricing system)

Now what would make life much better would be just say:
Select DocumentURL From Custom_Hotel_Document table
Where LinkedPricingHotelID = hotelID

I could then mix the URL into the transform and display the offer with the "more information" button linking to the value of DocumentURL from the above Select statement.

FYI LinkedPricingHotelID is unique to each Hotel.


I hope this explains what I am trying to do

Thanks

Jason

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 3/29/2011 9:44:40 AM
   
RE:Getting The URL Of a Document
Hello,

If you have only problems executing a custom query, then please check the following documentation. The developing form controls documentation covers how to work with data during the filling out of the form tab. Bram correctly pointed out what exact methods to use if you want to use the custom handler approach. You can access the data in the database in those methods and update any entry you like. If you have any other questions please state it clearly, because from the text, which describes nicely what you are trying to achieve isn't clear what problem you are having right now so I'm not able to give you a more specific answer. You should be able to achieve the described szenario with the answers in this thread.

Best regards,
Boris Pocatko

User avatar
Member
Member
Jason - 3/29/2011 10:16:54 AM
   
RE:Getting The URL Of a Document
Hi borisp,
Sorry for the confusion..
Yes what Bram said worked very well... Sorry I was just letting everybody know what I was doing in case somebody has a better way of doing it.

Thanks everybody my question has now been answered, and sorry for any confusion.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 3/29/2011 10:46:26 AM
   
RE:Getting The URL Of a Document
Hello,

That's fine, no harm done. I am glad you've got it working. Have a nice day.

Best regards,
Boris Pocatko

User avatar
Member
Member
Jason - 3/29/2011 3:24:15 PM
   
RE:Getting The URL Of a Document
Thanks Boris.

Jason