This is the archived version of my b2evolution code blog.
If you require any help regarding b2evolution then
visit it's support forums
You can find my current blogs here
Code : {@link : WafflesOn}
Personal : {@link : InnerVisions}
Posted on 2nd Oct 2009 in : Techno Babble
I *think* I've come to the conclusion that InnerVisions && WafflesOn won't be moving beyond the 2.x.x series of b2evolution. There's way to much shit in the 3.x+ series that I *really* don't want. With this in mind I'm going to start shutting down my code blog, all comments will be locked and any questions will be redirected to the evo forums. Eventually I'll archive it off to a "static" site ... not that hard really, it lives on it's own domain.
I'll continue to be active in the forums and will, obviously, support all our current plugins for every version they've been released for, and I'll (probably) bring them all up to the 3.x.eventually_stable series, if there's enough demand. Eventually I'll move them all into svn so other people are free to take them over.
BOPIT has already been moved to it's own sub domain, running it's own files/database, and other people have admin/ftp access, so I'm pretty sure it's going to continue ... I'll make sure it does huh? ... with a tad of luck it'll eventually be replaced by core functionality ... until then I'll keep it alive and kicking ![]()
For now it'll be based on 2.x.x, and I'll hack the core files to suit my/our clients needs. After that? I'm really not sure, and that's not a teaser ![]()
Yes. b2evo taught me many things, not least of which was php && mysql
For that alone I'm forever indebted ![]()
¥
Posted on 13th Jul 2009 in : Techno Babble
Unlike most of our other plugins this one does bugger all by itself, it's only reason for existence is to be used by other plugins and at the moment the only plugin that uses it is one that we're currently developing. So, what does it do? What this plugin does is allow your own plugins to easily add their own custom tabs to the admin area. Now, before any of yah point out that plugins already have the ability to easily add their own tab to the tools tab, I know, but this plugin allows you to add tabs to any of the evo tab pages ![]()
There's a couple of rules that your plugin has to play by to make all this work. The first and most obvious one is that it needs to declare this plugin as a dependency to ensure that it's always installed when you need it. You tell evo about dependencies by adding the following code snippet to your plugin.
PHP ( _your_plugin.plugin.php ) :
/** | |
* This plugin requires the AM Admin Pages plugin | |
* | |
* @return array dependencies | |
*/ | |
function GetDependencies() | |
{ | |
return array( 'requires' => array( | |
'plugins' => array( array( 'am_adminpages_plugin', 1 ) ), // requires at least version 1 of the plugin | |
)); | |
} |
Next you need to create a shiny new method in your plugin called GetAdminTabs() which should return an array of all tabs that you wish to add your tabs to, and the tabs that you wish to add ... it's probably simpler to just show you some code ![]()
PHP ( _your_plugin.plugin.php ) :
/** | |
* Add our tabs to the admin tabs | |
* | |
* @param array $params | |
* string 'main_tab' : This is the main b2evo tab that is currently being displayed | |
* @return array : our tabs | |
*/ | |
function GetAdminTabs($params) | |
{ | |
global $admin_url, $blog, $current_User, $user_ID; | |
global $AdminUI; | |
| |
$admin_tabs = false; | |
| |
switch( $params['main_tab'] ) | |
{ | |
case 'dashboard' : | |
case 'blog_settings' : | |
global $blog; | |
$bCache = get_Cache( 'BlogCache' ); | |
if( $blog && $sBlog = $bCache->get_by_ID($blog ) ) | |
{ | |
$shop_ID = $sBlog->owner_user_ID; | |
} | |
break; | |
| |
case 'users' : | |
$shop_ID = param( 'user_ID', 'integer' ); | |
break; | |
} | |
| |
if( empty( $shop_ID ) ) | |
{ | |
$shop_ID = 0; | |
} | |
| |
switch( $params['main_tab'] ) | |
{ | |
/* start snippet */ | |
case 'blog_settings' : | |
if( $this->ShopSettings->get('enabled', $shop_ID ) || $current_User->check_perm('blog_properties', 'edit', false, $blog ) ) | |
{ | |
$admin_tabs = array( | |
'blogs' => array( | |
'amsc_settings' => array( | |
'text' => $this->T_('Shop Settings' ), | |
'href' => url_add_param( $admin_url, 'ctrl=coll_settings&blog='.$blog.'&amat_tab=amsc_settings' ), | |
), | |
), | |
); | |
} | |
break; | |
/* end snippet */ | |
} | |
return $admin_tabs; | |
} |
The important thing to note in that code is the bit of the href which reads 'amat_tab=amsc_settings', this is the parameter that's used to tell our plugin which one of your custom pages you want to display, and it must have a corresponding function with the following naming convention function AdminTabPayload_your_unique_tab_value(). In the above example the corresponding function would be called AdminTabPayload_amsc_settings(), the following is our code for that function :
PHP ( Our Plugin ) :
/** | |
* Display our settings | |
* | |
* @param array $params | |
* string 'main_tab' : This is the main b2evo tab that is currently being displayed | |
*/ | |
function AdminTabPayload_amsc_settings($params) | |
{ | |
global $AdminUI; | |
| |
switch( $ctrl = param('ctrl', 'string' ) ) | |
{ | |
case 'dashboard' : | |
case 'coll_settings' : | |
global $blog; | |
$bCache = get_Cache( 'BlogCache' ); | |
if( $blog && $sBlog = $bCache->get_by_ID($blog ) ) | |
{ | |
$shop_ID = $sBlog->owner_user_ID; | |
} | |
break; | |
| |
case 'users' : | |
$shop_ID = param( 'user_ID', 'integer' ); | |
break; | |
} | |
| |
if( empty( $shop_ID ) ) | |
{ | |
$shop_ID = 0; | |
} | |
| |
$edited_settings = $this->ShopSettings; | |
$edited_settings->ID = $shop_ID; | |
global $Blog; | |
amsc_load_disp( 'shopsettings' ); | |
} |
The final thing you need to do is to inform evo of your shiny new abilities :
PHP ( your_plugin.plugin.php ) :
/** | |
* List of events that we handle | |
* | |
* @return array : events | |
*/ | |
function GetExtraEvents() | |
{ | |
return array( | |
'GetAdminTabs' => 'Adds all our required tabs', | |
'AdminTabPayload_amsc_settings' => 'Displays our settings', | |
'AdminTabPayload_amsc_info' => 'Displays our info', | |
'AdminTabPayload_amsc_customers' => 'Displays our customers', | |
'AdminTabPayload_amsc_invoices' => 'Displays our invoices', | |
); | |
} |
To make life a tad easier I've also coded a demo plugin that uses this plugin so you can (hopefully) see how it all works.
Anyway, enough blather from me, you can download the plugin here am_adminpages_plugin.zip and the demo plugin from here am_adminpagesdemo_plugin.zip
¥
Posted on 4th Dec 2008 in : Plugins & Widgets
There's been many a request on the b2evolution forums for a way to make blogs so that they can only be seen by members. The usual response has been "hack this file and then make sure that you make posts as protected" .... which is great and stuff, but it's hardly "friendly" when you have several blogs that need protecting and you also want a tad more than "are they logged in?". Soooooo, I made a plugin to do it for me ![]()
It's dead simple really, first go grab the plugin from BOPIT, unzip it, upload it, meander into admin and install it .... that was the hard part. For any blog that you wish to protect just put am:protected in the blog notes field and press save ...... and that's it! Instant protected blog ![]()
From now on when a visitor tries to reach any blog marked as protected they'll automatically be redirected to the login screen with a message of your choice being displayed to them to explain why. If a registered user tries to reach a protected blog that they're not a member of, they'll get sent back to your homepage ... or whatever you slapped into your $baseurl ... but you chose that.
As well as taking care of the visitors / non-members for you this plugin will also automatically change any posts created, or edited, with a status of "published" to "protected" if it's in a protected blog , just to be sure to be sure ![]()
I'm sure you'll let me know if it doesn't work,
¥
Posted on 9th Jun 2008 in : Plugins & Widgets
This plugin adds a shiny new tab to your users profiles tab in admin and allows your users to have such delights as avatars, signatures, location. It also adds the ability for each user to enter their time offset from the server and set the date and time formats that they prefer to use, although that bit means you need to do a tad of skin work
These extra profile fields, and settings, can then be used to enhance your current skin and there's also the ability to display each/any users profile instead of that ugly "edit profile" page that you get in the stock evo skins. There's a setting to allow you to restrict the viewing of profiles to logged in members so that the spamming arses don't get access to any details like aim/msn/etc
There's actually a couple of ways that you can call up the new settings in your skin. The individual methods are listed below. I'll ( try and ) explain the second method after them all ![]()
PHP:
<?php | |
$Plugins->trigger_event( 'UserAvatar', array( | |
'display' => true, // echo the results | |
'block_start' => '<div class="userAvatar">', // html used before the <img> tag | |
'block_end' => '</div>', // html used after the <img> tag | |
); | |
?> |
PHP:
<?php | |
$Plugins->trigger_event( 'UserSignature', array( | |
'display' => true, // echo the results | |
'block_start' => '<div class="userSignature">', // html used before the signature | |
'block_end' => '</div>', // html used after the signature | |
); | |
?> |
PHP:
<?php | |
$Plugins->trigger_event( 'UserSignature', array( | |
'display' => true, // echo the results | |
'block_start' => '<div class="userLocation">', // html used before the location | |
'block_end' => '</div>', // html used after the location | |
); | |
?> |
PHP:
<?php | |
$Plugins->trigger_event( 'UserSignature', array( | |
'block_start' => '<p class="userDateTime">', | |
'block_end' => '</p>', | |
'display' => true, | |
'output_format' => '$date$ @ $time$', // $date$ && $time$ will be replaced with users preferred format for date and time | |
); | |
?> |
PHP:
// for $Item use : | |
'localdatetime' => $Item->get( 'datecreated' ); | |
// for comments use | |
'localdatetime' => $Comment->get( 'date' ); |
An alternative method is to use the skintag call and pass it multiple parameters at the same time. It looks a tad more complicated but it really isn't that bad
Rather than repeat what's in the plugin code I'll just copy + paste it here and then try and explain it ![]()
PHP:
/** | |
* This is gonna be a doozy to write :p | |
* Displays all the various bits and bobs from the users profile | |
* Triggers event AMProfileSkinTag() to allow other plugins to hook in ;) | |
* | |
* @param array $params | |
* avatar - html output $avatar$ replaced with <img> tag for users avatar | |
* joined - html output $date$ && $time$ replaced with date/time user registered, display in current users preferred format and time offset | |
* location - html output $location$ replaced with users location | |
* name - html output $name$ replaced with users name ( replaces 'profile' if no linked profile ) | |
* posts - html output $posts$ replaced with total posts and comments by user | |
* profile - html output $profile$ replaced with profile link | |
* signature - html output $signature$ replaced by users signature | |
* website - html output $website$ replaced by website url, $name$ replaced with users preferred name | |
* no_guests - html output displayed when telling guests to piss off | |
* profile_display - boolean are we displaying the profile | |
* ouput_format - html output | |
* replacement vars | |
* $avatar$ - replaced with avatar html if set | |
* $joined$ - replaced with joined html if set | |
* $location$ - replaced with location html if set | |
* $posts$ - replaced with posts html if set | |
* $profile$ - replaced with profile html if set | |
* $signature$ - replaced with signature html if set | |
* $website$ - replaced with website html if set | |
* | |
*/ | |
function SkinTag( $params ) | |
{ | |
$params = array_merge( array( | |
'signature' => '<p class="userSignature">$signature$</p>', | |
'profile' => '<p class="userProfile">$profile$</p>', | |
'name' => '<p class="userName">$name$</p>', | |
'avatar' => '<p class="userAvatar">$avatar$</p>', | |
'datetime' => '<p class="userDateTime">$date$ @ $time$</p>', | |
'location' => '<p class="userLocation">$location$</p>', | |
'joined' => '<p class="userJoined">$date$</p>', | |
'posts' => '<p class="userPosts">$posts$</p>', | |
'website' => '<p class="userWebsite"><a href="$website$" title=" '.sprintf( $this->T_( 'visit %s\'s website' ), '$name$' ).' ">'.get_icon( 'www', 'imgtag' ).'</a></p>', | |
'no_guests' => $this->T_( 'You need to be a registered member to view profiles' ), | |
'profile_display' => false, | |
'output_format' => '', | |
), $params ); |
Looks simple huh ?
The main value is the output format, this is where you get to choose what's spat out and in which order. Continuing in my copy + paste fashion this is how it's called for the comments on my blog :
PHP:
<?php | |
$Plugins->call_by_code( 'am_profiles', array( | |
'obj' => $Comment, // change this to $Item for posts or $current_User for profiles | |
'profile' => '<span class="profileLink">$profile$</span>', | |
'name' => '<span class="userName">$name$</span>', | |
'avatar' => '$avatar$', | |
'posts' => '<p class="postCount">Posts : $posts$</p>', | |
'joined' => '<p class="userJoined">Joined : $date$</p>', | |
'location' => '<div class="userLocation">Location : $location$</div>', | |
'output_format' => '$profile$'."\n" | |
.'$avatar$'."\n" | |
.'$posts$'."\n" | |
.'$joined$'."\n" | |
.'$location$'."\n" | |
) ); | |
?> |
Displaying profiles is pretty similar to the code I pasted above. The main difference is that you want all fields and you pass on an extra parameter to tell the plugin that it's displaying the profile as opposed to just showing the users fancy new settings. When you do that the plugin will automatically trigger any other plugins that have the right hooks
Rather than re-pasting the sample profile pages code ( which is included in the zip ), you can see it here ( Sample _profile.disp.php ). You can just drop that page into your skins folder and it'll work
To enable other plugin developers to add their own profiles stuff this plugin adds a few new hooks. To use them you need to inform the core that you can react to them with the following :
PHP:
function GetExtraEvents() | |
{ | |
return array( | |
'AMProfileTabAction' => 'AdminTabAction() when on our profile tab', | |
'AMProfileTabPayload' => 'AdminTabPayload() when on our profile tab', | |
'AMProfileSkinTag' => 'Triggered when our SkinTag() is called', | |
); | |
} |
The events should be pretty self explanatory and are passed the following parameters :
PHP:
$Plugins->trigger_event( 'AMProfileTabAction', array( | |
'AMProfileUrl' => $this->url, | |
'user_ID' => $user, | |
) ); |
PHP:
$Plugins->trigger_event( 'AMProfileTabPayload', array( | |
'AMProfileUrl' => $this->url, | |
'Form' => & $Form, | |
'user_ID' => $user, | |
) ); |
PHP:
$Plugins->trigger_event( 'AMProfileSkinTag', array( | |
'AMProfileUrl' => $this->url, | |
'output_format' => $params['output_format'], | |
'user_ID' => $user, | |
) ); |
So, now that you've read all that, go download the plugin ( am_profiles.zip ) and enjoy your shiny new tab ![]()
¥
Posted on 2nd Jun 2008 in : Techno Babble
Finally, I've mostly integrated the old blogrum code with InnerVisions .... I've even started a tutorial on how to add a blogrum to your own b2evolution blog .... don't get excited though, it's nowhere near finished and I'm not in any great rush
. There's still a fair amount of work to do with it before it's anywhere near the end result I have in mind, and the skins a tad shagged in IE6, but I'll be re-skinning it as soon as I've got all the code working and testing, so either put up with it or switch to a browser that it does work in ![]()
I've decided that I can't be arsed importing all the current blogrums posts/comments/users, it's more hassle than it's worth so I'll just leave the current version where it is and shut down the ability to post/comment there. I also haven't redone the ability to create a new post from the frontend, I'll work on that when I get more free time. For the moment it's only linked in my drop down menus as I'd need to redo the header graphic to add it to the menu buttons, and I'm liable to go for a whole new skin if I have to go to that effort anyway ![]()
Anyway, feel free to have a play, and let me know if you find any bugs/quirks ![]()
¥
Posted on 16th May 2008 in : Plugins & Widgets
I decided to have a play around with my skins external links code, which uses javascript to add an onclick event to any links with class="ext", and a plugin I've had lying around for a fair smidge which does something similar for all/any external links by looking at the href for the link in question. The end result is a shiny new plugin which will add a graphic to every external link on your blog, clicking the graphic opens the link in a fancy little overlay which I stole from our photozoom plugin. I also threw in a few settings so that you can change the text that's added and add any domains that you class as internal links, although the plugin will auto generate an entry for each unique blog url on your system so you probably won't need to add any.
If you fancy having a play with this then you'll need to download 2 plugins as I've decided to separate the fancy javascript screen stuff into it's own plugin as I'm starting to use it in a couple of plugins and it's easier to have a dependency and maintain one codebase. You can download the external links plugin here ( am_externallinks.zip ) and the javascript helper plugin which it needs here ( am_jshelper.zip ), upload them both, install the js helper plugin and then install the external links plugin. That's pretty much it, now all your external links will have a crap looking arrow graphic which, when clicked, will open your link in a cool overlay. Your links will also have the class amExternalLink added to them so that you can style them as you wish. The arrow <img> tag will also have the same classname applied so you can change the graphic to suit your skin.
As always if you find any bugs or it melts your blog then just let me know ![]()
¥
Posted on 12th May 2008 in : Plugins & Widgets
NOTE : The chances are that none of this works in IE, so if you use IE you may as well skip the rest of this post ..... or read it and then go get a better browser ... whichever rocks your boat
So, I was playing around with the admin area to see what could be done using js, as it's required for the admin area to function anyway, and css. The main idea was to hide all of the clutter that's not used for the majority of posts, or only used briefly during the whole posting process, whilst also leaving it accessible for the moments that you do need it. When I say "clutter" I pretty much mean everything except the textarea that you type in and the post title. Toolbars - gone, advanced properties - gone, categories - gone, post status - gone, you get the picture ![]()
All of this is done from a plugin which hooks into a couple of the admin events and then unleashes a bit of javascript to play around with classnames and id's and onclick events and stuff. The rest is handled by a simple bit of css ...... so simple in fact that IE can't understand it ...... nothing new there then huh? ..... anyway, the end result is that pretty much everything in admin is collapsed or hidden until you hover over or click stuff. The toolbars will show on hover, or you can click the text to pin them open if you're going to be using them a lot for a particular post.
The whole of the right column is reduced to a lil tab handily marked "OPTIONS". Hovering over the tab brings the right column back so you can play with your categories, visibility and renderers and things. This allows the post textarea et el to be expanded to fill the width of the screen which, for me, makes posting far far easier ...... combine that with Afwas's plugin ( [2.4] Resize Admin Textarea plugin ) and you can pretty much fill your screen with just the post area ...... cool huh?
Finally a thanks to John for his constructive criticism and suggestions about the plugin ..... and for allowing me to scare the shit out of him when most of his admin area disappeared ..... I suppose I should have warned him first ![]()
Anyway, if you fancy having a play with this plugin, and you're using a decent browser, then you can download it here ( am_tidyadmin.zip ). If you find any bugs or flaws or stuff ( apart from "it doesn't work in IE", and variations of the same tune ) then just let me know.
¥
Page archived : 13th Dec 2009