View previous topic :: View next topic |
Author |
Message |
Joshua Clinard
Joined: 02 Dec 2002 Posts: 77
|
Posted: Thu Jan 09, 2003 7:27 pm Post subject: How to install b2 in seperate directory - UPDATED |
|
|
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
Code: | $pathserver = 'http://mydomain.com'; |
Change to:
Code: | $pathserver = 'http://mydomain.com/news'; |
b2config.php - Line 211
Code: | $smilies_directory = 'http://mydomain.com/b2-img/smilies'; |
Change to:
Code: | $smilies_directory = 'http://mydomain.com/news/b2-img/smilies'; |
b2archives.php - Line 5
Code: | require_once('./b2config.php'); |
Change to:
Code: | require_once('news/b2config.php'); |
b2archives.php - Line 6
Code: | require_once($b2inc.'/b2functions.php'); |
Change to:
Code: | require_once('news/b2-include/b2functions.php'); |
b2comments.php Line 51
Code: | <form action="<?php echo $siteurl; ?>/b2comments.post.php" method="post"> |
Change to:
Code: | <form action="<?php echo $siteurl; ?>/news/b2comments.post.php" method="post"> |
index.php Or wherever your b2 loop is:
Code: | <?php include ("b2comments.php"); ?> |
Change to:
Code: | <?php include ("news/b2comments.php"); ?> |
Code: | <?php include("b2archives.php"); ?> |
Change to:
Code: | <?php include("news/b2archives.php"); ?> |
That's it.
Thanks to nessahead and Cyberian75 for these mods.
Last edited by Joshua Clinard on Thu Jan 09, 2003 11:47 pm; edited 2 times in total |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Thu Jan 09, 2003 8:58 pm Post subject: |
|
|
I don't think there was an incompatibility issue. It was just that she didn't use some features, so she didn't include those.
Nice job you are doing by the way.  _________________ Michael P.
 |
|
Back to top |
|
 |
Joshua Clinard
Joined: 02 Dec 2002 Posts: 77
|
Posted: Thu Jan 09, 2003 9:43 pm Post subject: |
|
|
Ok, maybe incompatible was the wrong word. Some of the original code had been changed though, so someone looking for that exact code would not have found it to change. Also one of the lines was missing a semi-colin, and she totally left out line 6 in b2archives.php. I am guessing that line was added to b2 0.6.1.
All minor grievances. |
|
Back to top |
|
 |
nessahead
Joined: 12 Mar 2002 Posts: 312 Location: Los Angeles, CA
|
Posted: Thu Jan 09, 2003 10:52 pm Post subject: |
|
|
Thanks, Joshua, great work  _________________ raar! |
|
Back to top |
|
 |
Joshua Clinard
Joined: 02 Dec 2002 Posts: 77
|
Posted: Thu Jan 09, 2003 11:37 pm Post subject: |
|
|
Thanks. Just took a little bit of digging. And a little bit of help from Cyberian75!
Thanks to the both of you.
I just noticed something when looking at b2config.php.
Code: | # $b2inc is where the included b2 files are: that's generally the directory b2-include,
# so you shouldn't have to change that setting
$b2inc = './b2-include'; |
Maybe if I had changed the location listed in that code to something else, I wouldn't have had that fatal error with line 6. Who knows. I wouldn't have any clue what to change it to, since I don't know exactly what that ./ does anyway. |
|
Back to top |
|
 |
Biff
Joined: 29 Jan 2003 Posts: 4
|
Posted: Wed Jan 29, 2003 5:39 am Post subject: |
|
|
I think there are some additional modifications that need to be made.
First, in your index.php (or whatever)
Code: | <?php /* Don't remove this line, it calls the b2 function files ! */ $blog=1; include ("blog.header.php"); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
needs to be changed to:
Code: | <?php /* Don't remove this line, it calls the b2 function files ! */ $blog=1; include ("news/blog.header.php"); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Then, Line 1263 (at least in the LJ version) of b2functions.php:
Code: | require_once($b2inc."/lj_update.php"); |
should be:
Code: | require_once("news/b2-include/lj_update.php"); |
Even with that, the comment link is now pointing to the main directory (domain.com/commentspopup.php) instead of (domain.com/news/commentspopup.php).
The categories listing in each post are also refering just to (domain.com)
Any suggestions? |
|
Back to top |
|
 |
kichu
Joined: 23 Feb 2002 Posts: 53 Location: Chennai,India
|
Posted: Wed Jan 29, 2003 2:21 pm Post subject: |
|
|
Let me try to put things in proper perspective.
The changes in the hard coding indicated are applicable when you want to put the b2 engine in a folder called "news" and try to call the functions from another file located in another directory which is a subdirectory of "/" or from several other files in sitting in other directories.
Have I understood correctly?
If so, then I wish to point out that there are host of other things to be changes in several files like template.functions.php, archives.php and comments files.
Even after that, the "previous pages" and "next pages" things won't work. Macshack advised me to soil my hands with cvs files for that and I am presently trying to do that.
Well, if I am wrong and all that is discussed here is that the b2 files (all of them) are kept in a folder and in the root and called into action only from the index.php file residing in the same folder, then that is fairly very simple.
I am doing it right from the beginning.
Please throw a kindly light!!
Thanks
Regards
S.K _________________ Cause something to change, you are not here for ever! |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Wed Jan 29, 2003 6:54 pm Post subject: B2 in its own directoy with index.php eleswhere |
|
|
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"); |
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
Code: |
| |-b2-include/...
|-b2/--|-b2-img/...
| |
| |-b2config.php
| | ....
doc_root/-----|
(public_html) |-news/index.php
|
|-event/index.php
|
|-index.php
|
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.)
<?php comments_popup_script(400, 400, '/b2/b2commentspopup.php') ?>
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.
<?php include ("../b2/b2comments.php"); ?>
<?php include("../b2/b2archives.php"); ?>
The links to the login and register files: [Note again the absolute url path]
<a href="/b2/b2login.php">login</a><br />
<a href="/b2/b2register.php">register</a><br />
And if you have references to b2 images and files....
<a href="/b2/b2rss.xml"><img src="/b2/b2-img/xml.gif" alt="view this weblog as RSS !" width="36" height="14" border="0" /></a><br />
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.
Kind regards,
Michael e |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
Posted: Wed Jan 29, 2003 7:59 pm Post subject: |
|
|
This is a great writeup. thank you. |
|
Back to top |
|
 |
Joshua Clinard
Joined: 02 Dec 2002 Posts: 77
|
Posted: Wed Jan 29, 2003 10:06 pm Post subject: |
|
|
The comments works fine on mine, those changes are not neccesarry. The next, and previous links work too. |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Wed Jan 29, 2003 11:01 pm Post subject: |
|
|
Hi,
Joshua Clinard wrote: | The comments works fine on mine, those changes are not neccesarry. The next, and previous links work too. |
What "changes" are you refering to?
Michael e |
|
Back to top |
|
 |
kichu
Joined: 23 Feb 2002 Posts: 53 Location: Chennai,India
|
Posted: Thu Jan 30, 2003 5:36 pm Post subject: Re: B2 in its own directoy with index.php eleswhere |
|
|
macshack wrote: |
Set the siteurl to the place that is the main index for the journal:
$siteurl = 'http://www.yourdomain.com/news';
$blogfilename = 'index.php';
|
Ok.
But then how about /events/index.php?
And the paths for comments?
I think the following code has to be changed to tae the correct path of the file in b2template.functions.php Code: | function comments_popup_link
...........echo $b2commentspopupfile.'?p='.$id.'&c=1';..........
| And again in b2functions.php,
Code: | require_once($b2inc."/lj_update.php"); |
Regards
S.K _________________ Cause something to change, you are not here for ever! |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Thu Jan 30, 2003 8:45 pm Post subject: Re: B2 in its own directoy with index.php eleswhere |
|
|
kichu wrote: | macshack wrote: |
Set the siteurl to the place that is the main index for the journal:
$siteurl = 'http://www.yourdomain.com/news';
$blogfilename = 'index.php';
|
Ok.
But then how about /events/index.php?
And the paths for comments?
|
There is not an issue with the index in the events directory. If your think that there is a confict with the $siteurl, there is not. The siteurl is used in places where we want to go to the "main" page. Most of the time b2 is going to go back to where it came from unless directed otherwize. So other than the uniqueness of what is being done in the event page, there is nothing special about how the template is handled.
Quote: |
I think the following code has to be changed to tae the correct path of the file in b2template.functions.php Code: | function comments_popup_link
...........echo $b2commentspopupfile.'?p='.$id.'&c=1';..........
| And again in b2functions.php,
Code: | require_once($b2inc."/lj_update.php"); |
Regards
S.K |
Regarding the comments. No there is not a need to change $b2commentspopupfile if you do as i stated in my post. That's because it is set in the call to comments_popup_script() with the parameters passed as described.
And why to you think you need to change the include in b2functions.php?
Regards,
michael e |
|
Back to top |
|
 |
iolaire
Joined: 31 Jan 2003 Posts: 5 Location: Arlington, Virginia, USA
|
Posted: Fri Jan 31, 2003 3:43 am Post subject: broken b2commentspopup.php = fix b2template.functions.php |
|
|
Kichu pointed this out but I wanted to re-state it as it was the most dificult problem I encounted moving my blog to another folder once I got my includes set up correctly..
I place me blog in my site:
iolaire.mine.nu/current_site/blog.php
with the b2 files at:
iolaire.mine.nu/tools/b2/
Everything worked fairly well except for the b2commentspopup/pingback/trackback links were pointing to the current_site folder.
Thanks to Kitchu editing the b2template.functions.php file at line 773, to change the links from
$file='b2commentspopup.php' to
$file='../tools/b2/b2commentspopup.php' etc. fixed it.
Thanks,
iolaire |
|
Back to top |
|
 |
kichu
Joined: 23 Feb 2002 Posts: 53 Location: Chennai,India
|
Posted: Fri Jan 31, 2003 4:05 am Post subject: |
|
|
Thanks iolaire!
IMHO the whole issue is arising out of the fundamental logic on which b2 has been coded with regard to calling of different files into action by the script.
To wit, I am alluding to this statement in b2config.php fle:
"# by default b2 is set to run in the folder your blog resides, same as $siteurl"
So, I wish to request the php-coding experts like macshack and the host of other inmates of this forum who have been making b2 an experience more than a mere proggy, to give a comprehensive hack such that the following are achieved with minimum pain on the part of coding-challenged like me!
1. Ability to call b2 from any .php file residing in any folder and get the blogs appear in that file simply by including a single file which should contain all the calls to functions.
2.Ability to include one category or a selected number of categories at will without extensive hard-coding, but merely stating the ID of the category at one place and by including a single file as stated earlier in item no.1 (though this is possible now by stating upfront $cat_id=1; etc, many other functons do not work requiring further tweaking.)
Hope my wish will be fulfilled by the good samaritans!
TIA
Regards
S.K _________________ Cause something to change, you are not here for ever! |
|
Back to top |
|
 |
|