Math Paper by xkcd
If you have a specific job and can't find time or knowledge I offer custom support on a freelance basis. For both individuals and corporations I can set up single blogs and weave a B2evolution install into your existing site. Most often you will be looking for a specific custom job, like a skin based on your home page or corporate style, a plugin that fulfills your needs or upgrading an old install to the latest version.
As a member of the B2evolution support team ("Afwas") I have a thorough knowledge and understanding of the software and it's implementations. All the skins on this site are converted by me. I made a variety of B2evolution plugins, both custom and for the repository. I can advise you and help you with the lesser known features of the engine.
I will do both small jobs as well as complete sites. All my work will comply to XHTML and CSS standards.
I will normally charge € 20,- per hour. That will translate in these prices for smaller jobs (note: this is an indication only)
- Converting an existing skin: € 100,-
- Building a new skin from ground up: € 200,- / € 300,-
- Installing / upgrading B2evolution: € 50,- / € 100,-
I will gladly discuss your ideas and give you a price indication. Please email for more information.

DadHacker is the creator of the Atari game Donkey Kong. The game originated in 1981. Recently DadHacker wrote in his blog about his days at Atari and particularly about writing Donkey Kong. It's an incredible story.
If you cannot send mail through B2evo, probably because your host has disabled PHP's mail() function you must use another mailserver. There are other situations where you deliberately want to use this.
This solution will work with any SMTP server you have access to (can authenticate through username/password).
I had a successful go with Swift mailer in B2evo 1.10.3 and in 2.4.0 rc2. This is how to set it up:
1) Download swift-smtp from http://www.swiftmailer.org/download/ . Unpack and upload the /lib/ folder. I made a directory in /inc/_misc/ called swift-smtp where I put the lib folder. So this looks like /inc/_misc/swift-smtp/lib/. Feel free to add the folder to /htsrv/ where I think it belongs.
2) Open /inc/_misc/_misc.funcs.php and replace lines 2348 - 2362. If you are using B2evo v2.4.0 rc 2 look for this codesnippet in inc/misc/_misc.funcs.php line ~1568.:
PHP:
if( $debug > 1 ) | |
{ // We agree to die for debugging... | |
if( ! mail( $to, $subject, $message, $headerstring ) ) | |
{ | |
debug_die( 'Sending mail from | |
«'.htmlspecialchars($from).'» to | |
«'.htmlspecialchars($to).'», Subject | |
«'.htmlspecialchars($subject).'» FAILED.' ); | |
} | |
} | |
else | |
{ // Soft debugging only.... | |
if( ! @mail( $to, $subject, $message, $headerstring ) ) | |
{ | |
$Debuglog->add( 'Sending mail from | |
«'.htmlspecialchars($from).'» to | |
«'.htmlspecialchars($to).'», Subject | |
«'.htmlspecialchars($subject).'» FAILED.', 'error' ); | |
return false; | |
} | |
} |
by:
PHP:
//setup swift-smtp | |
require_once( dirname(__FILE__).'/swift-smtp/lib/Swift.php' ); | |
require_once( dirname(__FILE__).'/swift-smtp/lib/Swift/Connection/SMTP.php' ); | |
global $smtp_server, $smtp_user, $smtp_password, $smtp_port; | |
$smtp =& new Swift_Connection_SMTP( $smtp_server, $smtp_port); | |
$smtp->setUsername( $smtp_user ); | |
$smtp->setpassword( $smtp_password ); | |
| |
$swift =& new Swift($smtp); | |
$mail =& new Swift_Message( $subject, $message); | |
| |
$to_name = preg_replace( '/^.*?<(.+?)>$/', '$0', $to ); | |
$from_name = preg_replace( '/^.*?<(.+?)>$/', '$0', $from ); | |
$to_email = preg_replace( '/^.*?<(.+?)>$/', '$1', $to ); | |
$from_email = preg_replace( '/^.*?<(.+?)>$/', '$1', $from ); | |
| |
$new_to = new Swift_Address( $to_email, $to_name ); | |
$new_from = new Swift_Address( $from_email, $from_name ); | |
| |
if( $debug > 1 ) | |
{ // We agree to die for debugging... | |
if( ! $swift->send( $mail, $new_to, $new_from )) | |
{ | |
debug_die( 'Sending mail from | |
«'.htmlspecialchars($from).'» to | |
«'.htmlspecialchars($to).'», Subject | |
«'.htmlspecialchars($subject).'» FAILED.' ); | |
} | |
} | |
else | |
{ // Soft debugging only.... | |
if( ! @$swift->send( $mail, $new_to, $new_from )) | |
{ | |
$Debuglog->add( 'Sending mail from | |
«'.htmlspecialchars($from).'» to | |
«'.htmlspecialchars($to).'», Subject | |
«'.htmlspecialchars($subject).'» FAILED.', 'error' ); | |
return false; | |
} | |
} |
I prefer the variables in /conf/_advanced.php. Somewhere put this block:
PHP:
/** | |
* SMTP | |
* uses swift-smtp | |
*/ | |
$smtp_server = 'smtp.server.tld'; | |
$smtp_port = 25; | |
$smtp_user = 'user'; | |
$smtp_password = 'password'; |
If you want to put the Swift mailer files in the /htsrv/ folder (/htsrv/swift-smtp/lib/) you change these lines of the code:
PHP:
require_once( dirname(dirname(dirname(__FILE__))).'/htsrv/swift-smtp/lib/Swift.php' ); | |
require_once( dirname(dirname(dirname(__FILE__))).'/htsrv/swift-smtp/lib/Swift/Connection/SMTP.php' ); |
Once again: I took the /lib/ folder from the package and put it in a custom made /swift-smtp/ folder. You may copy the /lib/ folder from swift-smtp directly to the /htsrv/ folder, but change the path accordingly.
Thanks to dcihon for testing.
Good luck
Wouldn't it be nice to be able to change the skin's appearance based on some condition. In this tip & trick I'm going to change the colour of this post to red at daytime and blue at night. Times are local CET (Europe).
The nice thing about PHP is that you can deploy it everywhere in the page. So why not within the CSS file.
First you want to point to this special file. Somewhere in the header (for B2evo that's ../blogs/skins/YOURSKIN/_html_header.inc.php) make this call:
Code:
<link rel="stylesheet" href="phpstyle.php" type="text/css" /> |
Every PHP statement must be within a PHP file. We create this phpstyle.php file and start it with:
Code:
<?php header("Content-type: text/css"); ?> |
That's about it. The file acts as any other CSS file, but since it's a PHP file we can interweave (we say 'lard' in Holland) with any thinkable condition. It's like serverside JavaScript.
On with the task I've set. Let's call the server time:
PHP:
$time_at_server = date(G); | |
$time_in_europe = $time_at_server + 9; |
Now the condition:
PHP:
if ($time_in_europe >= 6 && $time_in_europe < 18 ) | |
{ | |
// It's daytime | |
$sun_is_shining = 1; | |
} | |
else | |
{ | |
// it's night | |
$sun_is_shining = 0; | |
}; |
This is the complete phpstyle.php:
PHP:
<?php header("Content-type: text/css"); ?> | |
<?php | |
$time_at_server = date(G); | |
$time_in_europe = $time_at_server + 9; | |
// Found a bug. This is the fix: | |
if ( $time_in_europe > 23 ) | |
{ | |
$time_in_europe = $time_in_europe - 24; | |
} | |
if ( $time_in_europe >= 6 && $time_in_europe < 18 ) | |
{ | |
// It's daytime | |
$sun_is_shining = 1; | |
} | |
?> | |
| |
.day_or_night p { | |
<?php | |
if ( $sun_is_shining ) | |
{ | |
echo ( "color: red; \n" ); | |
} | |
else | |
{ | |
echo ( "color: blue; \n" ); | |
} | |
// output | |
/** | |
* .day_or_night p { | |
* color: red; | |
* } | |
* | |
*/ | |
?> | |
} |
I've started this post with <div class=" day_or_night"> and ended it with </div>.
That's it. I Hope you like it. Can you think of some other uses for this conditional css statements? Leave a comment if you do.
Have fun.
Adding an extra item to the menu (blogroll) in B2evolution -like the forum link in this blog- should be easy, and fortunately it is. It requires a minor hack though. The development team and especially ¥åßßå promised a solution for the 2 branche. Until that time you'll have to do with the hacks.
For 1.10 and earlier do this:
In ../blogs/skins/_bloglist.php add before:
PHP:
// Output: | |
echo $blog_list_start; | |
echo implode( $blog_list_separator, $blog_links ); | |
echo $blog_list_end; |
this piece of code:
PHP:
/* Start hack to add static links to blog bar */ | |
/* Compose the link from various existing pieces */ | |
$extra_blog_link = $blog_item_start; | |
$extra_blog_link .= '<a href="'; | |
$extra_blog_link .= 'http://www.b2evolution.net'; /* URL */ | |
$extra_blog_link .= '" class="'.$blog_other_link_class.'" title="'; | |
$extra_blog_link .= 'B2evolution website'; /* title (mouse over) */ | |
$extra_blog_link .= '">'; | |
$extra_blog_link .= $blog_other_name_before; | |
$extra_blog_link .= 'B2evolution'; /* title in label */ | |
$extra_blog_link .= $blog_other_name_after; | |
$extra_blog_link .= '</a>'; | |
$extra_blog_link .= $blog_item_end; | |
| |
/* Add to existing blogs */ | |
$blog_links[] = $extra_blog_link; | |
/* Repeat all previous steps for more links */ | |
| |
/* End hack */ |
and change it to your preferences.
You may or may not want to add 'target="_blank"' in $extra_blog_link .= '">'; like so:
PHP:
$extra_blog_link .= '" target="_blank">'; |
In B2evo v 2.1 you need to hack a quit different file: ../blogs/inc/widgets/model/_widget.class.php. Find this piece of code and add the 'Forum hack' to it:
PHP:
if( $Blog [amp]amp;[amp]amp; $l_blog_ID == $Blog->ID ) | |
{ // This is the blog being displayed on this page: | |
echo $this->disp_params['item_selected_text_start']; | |
echo $l_Blog->dget( 'shortname', 'htmlbody' ); | |
echo $this->disp_params['item_selected_text_end']; | |
echo ''; | |
echo $this->disp_params['item_selected_end']; | |
} | |
else | |
{ | |
echo $this->disp_params['item_text_start']; | |
echo $l_Blog->dget( 'shortname', 'htmlbody' ); | |
echo $this->disp_params['item_text_end']; | |
echo ''; | |
echo $this->disp_params['item_end']; | |
} | |
} | |
/* | |
* Add forum to bloglist | |
* | |
*/ | |
echo '<li><a href="http://www.forum.hemminga.net" class="default" title="Forum">Forum</a></li>'; | |
// End Forum | |
| |
echo $this->disp_params['list_end']; | |
| |
echo $this->disp_params['block_end']; |
I will update this post once the New version is out.
Happy blogging