Can we have multiple content types with same fualias?

#1

Is is possible to have multiple content types with the same / dir / friendly url?

IE

dmNews.cfc, dmBlog.cfc, dmOpinion all have fualias=“latest” generating the same “latest/” url structure.

Would that really make things wonky?

#2

That will cause issues in a few places.

Blair

#3

You can’t re-use the same fualias on multiple types (it needs to be unique so that the framework knows which content type to call the “type webskin” on when there is no friendly URL match found in the database), but you can generate any custom URL you like for your content types, and they can share the same URL stem.

So if you wanted your news, blog and opinion content types to all have URLs like;

/latest/this-is-a-news-item
/latest/this-is-a-blog
/latest/this-is-an-opinion-piece

Then you can implement a displaySystemFU.cfm webskin for each of the content types;

<cfsetting enablecfoutputonly="true" showdebugoutput="false"> 

<!--- return the friendly url --->
<cfoutput>/latest/#stObj.label#</cfoutput>

<cfsetting enablecfoutputonly="false">

Note that the webskin is only outputting a single line. Spaces and other unallowed characters in the URL path will get converted by the framework automatically just as they would if you used them in a page title.

Here’s another example for a more complex custom friendly URL;

1 Like
#4

This looks great @justincarter. So you would leave the fualias empty in the cfc correct? And drop in the fu display skin for each of the types you wanted to “override”?

#5

You could keep a unique fualias for each content type if you wanted to have a landing page for them separately (e.g. /news, /blogs, /opinion) but if you don’t need that then an empty fualias should be fine.

And yes, drop the friendly URL webskin into each type that you want to customise :slight_smile:

#6

@justincarter one last question, I had experimented with the FUAlias decorator with no luck before posting this. I thought that would do what your displaySystemFU.cfm does to accomplish my need for multiple types of the same URL structure. Can you explain the FUAlias decorator?

@@Fualias: friendly URL alias for the view
Friendly URL alias is great. You can rename your view, as it appears in the URL, to just about anything you like. So for a view with a file name of displayRSSFeed.cfm you get a default URL containing "displayRSSFeed". Using fualias you could change this to simply "RSS".

-via http://blog.farcrycore.org/com.posterous.farcry/posts/2010/07/quick-summary-of-farcry-view-decorators.html

#7

You could keep a unique fualias for each content type if you wanted to have a landing page for them separately (e.g. /news, /blogs, /opinion) but if you don’t need that then an empty fualias should be fine.

And yes, drop the friendly URL webskin into each type that you want to customise :slight_smile:

Just a note to those who are coming across this. You need to republish any published entries to get this to work. It actually overrides the URL at the DB level. So in my example of a content piece being published with opinion/my-opinion-piece I would need to drop in the skin to override, then republish and my opinion piece becomes latest/my-opinion-piece

Also of note, FC smartly archives the old url, so the old path 301’s (I assume) to its new path, but that old url will still render to the new url

#8

The @@fualias decorator on a webskin allows you to give the webskin itself a friendly name, so that you can more easily refer to it in a URL or use getLink to look it up via the alias when generating a URL. It would be used for URLs like;

/news/rss
/news/this-is-a-news-item/preview

Where “rss” is the fualias for a displayTypeRSS webskin on news, or “preview” is the fualias for a displayPagePreview webskin on news which outputs a limited view of an article.

1 Like
#9

This is complete, thanks for all the help

#10

With regard to the issue of needing to republish entries… is there a way to trigger the modification programmatically? I have a lot of new URLs that suddenly need to be created.

#11

Yes, in the webtop under Admin -> Developer Tools -> Rebuild Friendly URLs, you can regenerate the system URL for the content types that you want to refresh. It should archive the old system URLs so that it redirects too.