# INSTALLING b2 in a SEPERATE DIRECTORY # Source: http://cafelog.com/board/viewtopic.php?t=2014 There are probably more than two ways of doing this, but i chose to include these two in this file, because they were well-documented. A look at the source (above) may be a good idea, though. Sigg3. # ALTERNATIVE 1 # by Joshua Clinard Thanks to Nessahead and Cyberian75 This modification was originally posted by nessahead, but a few lines of code have been changed in the latest version of b2, and there is one function that no longer works. Therefore, I am posting a new version of this modification, which has been tested with b2 0.6.1, so that people can easily install it without having to read every post in the other thread. I chose to install b2 in a directory called news. b2config.php - Line 35 $pathserver = 'http://mydomain.com'; Change to: $pathserver = 'http://mydomain.com/news'; b2config.php - Line 211 $smilies_directory = 'http://mydomain.com/b2-img/smilies'; Change to: $smilies_directory = 'http://mydomain.com/news/b2-img/smilies'; b2archives.php - Line 5 require_once('./b2config.php'); Change to: require_once('news/b2config.php'); b2archives.php - Line 6 require_once($b2inc.'/b2functions.php'); Change to: require_once('news/b2-include/b2functions.php'); b2comments.php Line 51
Change to: index.php Or wherever your b2 loop is: Change to: Change to: That's it. Thanks to nessahead and Cyberian75 for these mods. # ALTERNATIVE 2 # by Michael e a.k.a macshack A number of users have attempted to install b2 in a subdirectory of the document root while placing the main and other template files(index.php) in a parallel directory (or elsewhere). Several of these users have chosen to do surgery on the b2 files to correct "reference" issues when in most cases it is not necessary. I will refer to a real case that is being done for a Rotary International club to try and explain what needs to be done. First, B2 is installed in its own directory right from the distribution. At the main site level there are a couple of directories that deal with b2 content. One is the 'news' and the other is 'event'. While I will not discuss what event is, it is however a b2 template referencing the b2 files as would a normal journal. Thus a url of http://www.mydomain.com/news should produce a page that is built form the b2 journal posts. To do this several things need to be kept in mind. The most important of which is where the index file is in reference to the b2 files. In most cases, include references must be relative to the file that makes the include reference. For example, using the tree below as a reference, the news index.php file must refer to the blog.header.php file to get the needed b2 stuff 'included'. In this case, that relative reference requires us to go up one level, and then reference the b2 directory. Therefor the include would look like this [Code] include ("../b2/blog.header.php"); [/code] On first look this looks like a great number of changes are going to be needed to get b2 to work in this environment. But in reality it is not much at all. site structure This is a live case; the site is structured like this [Example of tree] | |-b2-include/... |-b2/--|-b2-img/... | | | |-b2config.php | | .... doc_root/-----| (public_html) |-news/index.php | |-event/index.php | |-index.php [/example] Note that b2 is in its own directory and that the news and event directories have index pages that pull things from b2. So what needs to change to do this? Not much. Yes, you could go into b2 and start carving away, but in most cases it is not necessary.... In b2config.... Set the siteurl to the place that is the main index for the journal: $siteurl = 'http://www.yourdomain.com/news'; $blogfilename = 'index.php'; $blogname = 'Site name to display'; $blogdescription = 'Offical Web Site of whatever'; ....... Set the pathserver to the url of where the b2 files are at: [Note this will be different than the siteurl] $pathserver = 'http://www.yourdomain.com/b2'; Set b2inc to the directory name of where the includes are. [Note there is no reference to the 'b2' directory at all. It is just the directory name.] $b2inc = 'b2-include'; In the index file... Again, we are taking into account where the reference file is and what needs to happen for the includes. Reference to blog.header.php needs attention: [Note relative reference] include ("../b2/blog.header.php"); The reference to the css file (and note that urls in the css file may need attention) [Note that in this case and other to follow, this is an absolute URL path] @import url( /b2/layout2b.css ); In the case of the popup comments, we give a hard path of where the comments script is, that way we don't need to modify b2comments or the commentspopup. Because what we want to define is the third parameter, we must also define the first and second (this is the window size fo the popup.) In the body area, relative paths to the b2 elements from the reference point of view. Here the index file is in a directory named news at the document root level therefore: back one level, down into directory b2 to get the include file. The links to the login and register files: [Note again the absolute url path] login
register
And if you have references to b2 images and files.... view this weblog as RSS !
b2archives.php.... The require will need attention. In most cases we would be refering to this file (b2archives.php) from the index page. Thus the need to make the adjustment so we reference the correct location of the config file. If there is a need to do a direct reference to this file, it should still be ok. require_once('../b2/b2config.php'); This will not suffice if the reference file(index.php) is at one level and the b2archives.php is at a different level and you what to do a direct reference as well. In that case some creative code will be needed, but that is beyond the scope of this topic. There you have it. Very little code was change in b2 proper. Attention to config.php details, and references in the index.php templates were all that is needed. I Hope that this is of some help and sheds some light on how to go about placing b2 in its own directory while the index pages are outside that location. Source: http://cafelog.com/board/viewtopic.php?t=2014