Question on friendly URL

25 views
Skip to first unread message

funandlearning

unread,
May 9, 2012, 9:47:37 AM5/9/12
to farcry-dev
Hi All -

I am new to farcry and looking at some existing code. I have a
question on friendly URL. At what time of the application do the
actual URL gets parsed to friendly URL.

Suppose I have a href link as

<a href="www.example.com?objectid=123askjhdakjshdkasjhd">Go to new
page</a>

When I click the above link, the new page URL is a friendly URL. I
checked in onApplicationStart, but the URL is constructed even before
that. Can you let me know at what time is the URL parsed, and which
function does it? Is it fixURL function in utils.cfc?

Blair McKenzie

unread,
May 10, 2012, 1:18:09 AM5/10/12
to farcr...@googlegroups.com
Do you mean the point where the user is redirected from that URL to the friendly one? The FU handling is done in onRequestStart in core's application.cfc. If the user is using a non-friendly url at that point, and the application supports friendly urls, FarCry will redirect the user.

Blair


--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry

funand learning

unread,
May 10, 2012, 8:45:18 AM5/10/12
to farcr...@googlegroups.com
Thanks for responding Blair. Yes thats what I meant. Can you tell me if the following part of the code does that?

<cfif structKeyExists(url, "returnURL")>
       <cfset session.loginReturnURL = application.fapi.fixURL(url.returnURL) />
</cfif>

funand learning

unread,
May 10, 2012, 8:48:41 AM5/10/12
to farcr...@googlegroups.com
I am sorry, I wanted to know when is the variable FURL created? Which function of coldfusion code takes the objectid from the URL and converts into FURL?

Justin Carter

unread,
May 10, 2012, 9:06:12 AM5/10/12
to farcr...@googlegroups.com

The furl variable in the URL is usually created by the rewrite rules on the web server before the request is sent through to ColdFusion, so you'll need to look in the appropriate place depending on which web server you are using. Commonly it will be mod_rewrite rules in your vhost configuration in Apache, or IIRF / IIS Rewrite for IIS.

If the friendly URL rewrite rules are already set up correctly for your web server then you will typically not need to change them :)

Cheers,
Justin

funand learning

unread,
May 10, 2012, 9:29:59 AM5/10/12
to farcr...@googlegroups.com
Ok I am able to understand this slowly. So furl is set by the web server. Can you tell me if the following steps are right?


2) This URL is converted toFURL by webserver during onrequeststart method of coldfusion (am I right?)

3) When webserver tries to convert, how does it know which table to query? Suppose in my case, for the above example URL, the fURL looks like www.example.com/abc-hello-world. SO the for above url variable objectid, "abc-hello-world" is retreived from the database to append to the URL. When and how is this done by web server?

Thanks

Sean Coyne

unread,
May 10, 2012, 10:33:25 AM5/10/12
to farcr...@googlegroups.com
If the user requests the url you have in 1, then it will go directly to that page.  Core's Application.cfc's onRequestStart method will look to see if FUs are enabled and if so, redirect to the FU.  The FU is rewritten by your webserver into /index.cfm?furl=/whatever/the/fu/is format.

Does that make sense?

Jeff Coughlin

unread,
May 10, 2012, 10:41:44 AM5/10/12
to farcr...@googlegroups.com
If you're interested in the underworkings of FarCry with regards to how it converts objectIds to FU names, take a look at core/packages/types/farFU.cfc.  All the methods are in there.  ie. If you have an objectId and want to get the FU name, you might want to try getFU().

Regards,

--
Jeff Coughlin

funand learning

unread,
May 10, 2012, 12:10:52 PM5/10/12
to farcr...@googlegroups.com
Thanks Jeff. Where is getFU method called? I mean during which method of Application.cfc? I tried searching for it,  but I need to know if someone has a quick answer to my questions. Thanks.

Jeff Coughlin

unread,
May 10, 2012, 12:36:40 PM5/10/12
to farcr...@googlegroups.com
In application.cfc FarFU's parseFU() method is called from within farcryRequestInit().  My guess is that it does its work from there.

--
Jeff Coughlin

Blair McKenzie

unread,
May 10, 2012, 7:13:43 PM5/10/12
to farcr...@googlegroups.com
What is the problem you're trying to solve? You're asking a lot of questions about the underlying workings of FarCry, but there is no way to give you a complete understanding "quickly". On the other hand, if you tell us the problem we may be able to tell you the "FarCry way" to solve it.

Blair

funand learning

unread,
May 11, 2012, 12:19:33 PM5/11/12
to farcr...@googlegroups.com
Well, I have a situation where an item falls under two different categories, but the URL should show the main category.

Suppose item1 falls under category1 and category2, and category1 is the main category, the URL for the item should always be www.example.com/category1/item1 even if the item is accessed from category2....Sometimes when I use preview to view the page, the url shows as www.example.com/category2. So somewhere there must be a query which is retrieving the category values to  construct the URL. I would like to write a condition in the query on what category should be displayed in the URL

I hope I made my problem clear. 

Matthew Williams

unread,
May 11, 2012, 5:50:39 PM5/11/12
to farcr...@googlegroups.com
You should be able to see all the FUs assigned to an object from the
webtop. From there, you can assign the /category2/link to be a 301
redirect to /category1/link.

--
Matthew Williams
Geodesic GraFX
www.geodesicgrafx.com/blog
twitter.com/ophbalance

Jeff Coughlin

unread,
May 11, 2012, 6:01:27 PM5/11/12
to farcr...@googlegroups.com
Yeah, this feature is already built into FarCry.  You might be reinventing the wheel rather than asking if the feature already exists and how to use it?  FarCry makes it super easy to add multiple FU's per object (setting one of them as the default and the others as redirects).

Go to the overview screen for any object, click on the SEO tab, and manage the FUs for that object there.  You can programmatically add them as well if thats what you need.

--
Jeff Coughlin

funand learning

unread,
May 17, 2012, 2:42:28 PM5/17/12
to farcr...@googlegroups.com
Thanks Jeff. I understood about the SEO tab now. Please bear with me and my questions, here is another one. So when I create some new content in webtop, is a default FU created then? I mean when I see the SEO tab of overview screen, I see a default FU that is being fetched from farFU (with inner join on refobjects). When is defaultFU created and saved to farFU table? 

Note: I am new to this project, and still going around talking to people how they are using webtop, but meanwhile doing my own research

Thanks.

Jeff Coughlin

unread,
May 17, 2012, 3:05:22 PM5/17/12
to farcr...@googlegroups.com
Check out the docs for Friendly URLs.  Specifically the section that talks about "Customizing Friendly URLs per Object Type".  See the following link https://farcry.jira.com/wiki/display/FCDEV50/Friendly+URLs#FriendlyURLs-CustomizingFriendlyURLsperObjectType

If you want to create your own displaySystemFU.cfm, first copy the one from core (see core/webskin/dmNavigation/displaySystemFU.cfm), place it in your project's webskin forlder for the appropriate type ([myProject]/webskin/[myCoolType]/displaySystemFU.cfm, and modify it as desired.  If it's a new file, you may need to updateApp for the system to see it.

Regards,

--
Jeff Coughlin

AJ Mercer

unread,
May 17, 2012, 6:26:11 PM5/17/12
to farcr...@googlegroups.com

funand learning

unread,
May 18, 2012, 9:30:09 AM5/18/12
to farcr...@googlegroups.com
Thanks Jeff and AJ
Reply all
Reply to author
Forward
0 new messages