YAFLogo

rich.kopelow
13 years ago
Hi,

I'm running YAF 1.9.5.5 on a Godaddy hosting account under windows IIS 7.

I have "fully" integrated the forum into my existing site. The main problem I'm seeing now is that I can't seem to get a consistent "custom" location for the board files. I don't want to merge all of the files into my page root directory for independence. I have created a YAFBoardFiles directory in my site and have the following line in my app.config file:

I've copied a number of the directories from the YAF project there including the themes, resources, controls, pages, etc. But the forum pages that are generated seem to only be using the fileroot (I've tried boardroot as well.)

In the page source below some links point to /test/Themes and some point to /test/YAFBoardFiles/Themes! Shouldn't these be the sam?

href="/test/Themes/cleanSlate/theme.css" rel="stylesheet" type="text/css" />

Thanks in advance for any help.

Rich.

Sponsor
logan
  • logan
  • 100% (Exalted)
  • YAF Leader
13 years ago
Assuming you want the url to be Yoursite.com/YAFBoardFiles/Default.aspx

Use in app.config

 <add key="YAF.AppRoot" value="~/YAFBoardFiles" /> 

All YAF files will be in this folder - and is not set as an application root

except app.config,db.config,Urlrewriter.config, mail.config and your merged web.config these go in the root.


test
rich.kopelow
13 years ago
Thanks for the reply... I've been working on this quite a bit and the problems go fairly deep.

I'm not branching to a new set of pages for the forum. I'm simply using the link in one of my pages. I can't use the approot because that effects many links and in the end causes many other side effects. The fact is my app is rooted at "/".

I've ended up rewriting the the "entire" folder handling. As I see it there are several important locations to anyone who is integrating YAF into an existing site.

AppRoot - base website location

YAFCodeFolder - where all of the YAF non-binary code sits (i.e. pages, editors, controls, languages, resources)

YAFBoardFolder - where all of the board content would sit (i.e. images, themes)

I'm not really sure how AppRoot is used. In any of my environments approot doesn't need to be used, but let's go with it.

Currently, YAF mixes, matches and ignores serverfileroot and boardroot in so many varied ways that I just can't make all of the board related files exist in only one directory (other than the root). In my case I want to have a single board and have ALL of the board files (except the binaries) in directories that hang off of a single subdirectory.

The problem is compounded by the fact that I develop on a local machine and am publishing to a subdomain. YAF attempts to adjust for subdomains, but it does so by prefixing boardroot with the subdomain directory and that means that you can't use approot as an offset anyway because you would get approot/subdomain/boardroot, which wouldn't work. Fileroot seems to be "added" as well, so you can't use fileroot for the code files and boardroot to point to the board files. I tried many combinations and just couldn't make it work.

I see the following "formulas" for the "new" YAF... folders above:

YAFCodeFolder - /approot(config param)/subdomain(automatic)/coderoot (new config param)/

YAFBoardFolder - /approot(config param)/subdomain(automatic)/boardroot (config param)/[optional board ID for multiboard use]/

(Of course the above folders would need to be cleaned up to handle multiple "/"s etc.)

So what I did was modify the the BaseUrlBuilder and a few other routines to produce code and board folders as above, then I modified the YAFForumFolders class to include every special folder (the ones listed above and some of their subfolders).

Then I started wiping out any reference to ForumClientFileRoot, ForumServerFileRoot, etc. and replaced them with calls to YAFBoardFolders methods. This way if I ever need to adjust what's in what folders it can all be controlled in one place. I also removed the "second hand" path calculations. Often when folders are reference they are prepended by approot or build on the fly. With this change none of that is required.

I now have the site running (both local and in a test subdomain) with my main site in one directory and all of the board files sitting in a single subdirectory. I'm not using any of the YAF aspx pages, I'm using the forum control on one of the pages in my main site.

I haven't made it yet, but I envision that whether a particular folder hangs off of the code folder or off of the board folder should also be configurable (i.e. in a multiboard environment, you might want to customize the resources or the images and in that case you'd want them to hang off of the board folder, otherwise save the space and hang it off of the code folder.)

Seems to be working now...

Thanks,

Rich.

rich.kopelow
13 years ago
So, I've taken this one step further... I realized that the most general method would be to treat the two config parameters (CodeRoot and BoardRoot) as format strings. This way they can simply be used exactly the way they are now (without even knowing about the change) or make use of the ability of being able to develop complex, highly custom folder paths. The code change is:


string rootFmt = Config.CodeRoot;
string altRoot = string.Format(rootFmt, Config.AppRoot, HostingEnvironment.ApplicationVirtualPath,
YafControlSettings.Current.BoardID);

This allows an appconfig lines like:

(The first two are equivilent if approot is "/".)


  <add key="YAF.BoardRoot" value="~/YAFBoardFiles/" />
  <add key="YAF.BoardRoot" value="/{1}/YAFBoardFiles/" />
  <add key="YAF.BoardRoot" value="/{1}/YAFBoardFiles/{2}/" />
  <add key="YAF.BoardRoot" value="/{1}/YAFBoardFiles/{2}/data/" />

This is done now. No more directory issues.

Rich.

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
13 years ago
There is already configuration for:

YAF.ClientFileRoot

YAF.ServerFileRoot

You might want to try those.