This is the archived version of my b2evolution code blog.
If you require any help regarding b2evolution then
visit it's support forums
Other destinations :
Plugins : {@link: Plugins}
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 6th Jun 2009 in : Techno Babble
I've recently found myself in the position where a client has offered to drop ship for me, partly to give me greater freedom of layout/content/style than they'd be happy to risk on their own domain and partly to see if I could come up with some form of drop shipping "template" that could then be rolled out to a wider audience ... either way they're to cheap to pay me the development hours
... So, now I have a conundrum, do I attempt to bend an existing shopping cart to work ( and look ) the way I want it, or do I try and bend b2evo into being an e-commerce solution?
Each has it's own advantages, using off the shelf e-commerce software means that it already does all the tedious stuff required for a shopping cart to function, but I'd spend god knows how many man hours learning the system, and especially the code, before I could begin to use it for a drop shipping site. On the other hand, I'm not to shabby with the evo code base so I'd be able to crack on and add all the custom stuff required to make this all work ... within my lifetime. The downside of using b2evo is that it's not exactly geared up to be an e-commerce solution out of the box.
I guess it all comes down to "which is the better use of my time?", currently my thoughts are "use an e-commerce package and face the 'now make it available to a wider audience' bridge when I get there", by then the chances are that I'd have a much deeper knowledge of the chosen packages code base and in the meantime I could make a few quid ... but ... there's always a "but" huh? ... *if* I went the evo route then I'd save myself a load of learning and, if I needed to, I could change the core in cvs to add any hooks 'n' stuff that would make my life easier long term.
So ... hands up if you think I should go the evo route
¥
Posted on 13th Jan 2009 in : Plugins & Widgets
As the title says, you have Topanga to thank for this plugin because she paid us to code it, with the explicit condition that it could be freely released to the community once it was finished(a), because thats kinda what OSS is about huh? As a part of that condition the AstonishMe Team has decided that we won't fully release(b) this plugin on BOPIT until after the value of it has been made in donations to Topanga. Now, before you all start shaking fingers at us and prodding us with sticks, I should tell you that Topanga will be donating all of the donations she gets for this plugin to Kiva.org and, because we didn't really want paying for this in the first place, we'll be donating the fee to Kiva ourselves .... who said life was simple? ![]()
This plugin allows you to add custom fields to your posts, so if you're the sort that likes to add "mood", "listening to" and all the other stuff then this is the plugin for you! Once you've installed the plugin you'll be able to add fields to any/all of your blog posts by clicking the nifty little "add new field" button somewhere under your post field ... exactly where kinda depends on if you're in simple or expert mode ... but it'll be there ![]()
To make life a little bit simpler each user can have a set of default fields that are added to every post, the fields are only shown if they're filled in so it doesn't really matter how many defaults you have. To make things slightly easier for blog admins they can use the plugin settings to specify the default user settings.
Because of the complexity of what Topanga wanted, and seeing as she was paying we had to listen to her, we decided to make the displaying of the fields a widget. This allowed us to add in filters and custom html and other wild and wacky stuff that makes a sunday a brighter place, but because we knew that you lot would bitch if we forced you to add a container to all your skins, we added a shiny new plugin setting for choosing whether to automatically add the fields to the start or the end of your post content .... so new in fact that it's not in the screenshot
... so if you want the easy life just pick top or bottom and press save ... be aware though, if you choose automatic mode then it won't do anything as a widget ![]()
As mentioned, this plugin can also be used as a widget that can be thrown into any container you like. If you slap it in one that's inside the post loop then it'll strut it's stuff for each post, but if you slap it outside then it'll attempt to use a single posts stuff ... so it can survive happily enough in the sidebar of your page.main.php / single.main.php
If you look at all the widget settings then they'll hopefully make sense to you ... if not then feel free to donate and then demand further instructions
.... the chances are you'll pretty much just want to slap it in your container of choice and leave the settings at default ![]()
You can get the latest version of the plugin here ( AM Custom Fields ). Whilst you wait for it to download we'd like you to consider hitting the donation button on the left and donating what you can towards our Kiva fund. This fund will be used to sponsor projects on Kiva. You can visit our Kiva Lender page at any time to see the current status of our ongoing projects.
(a) Is this explicit enough?
topanga: if you work for me, then I'll pay you
topanga: if you give it away
topanga: then that is other things
yabba_hh: what if I work for you and then I give it away?
topanga: then at least, it will be something that is written especially for my needs
topanga: and if others want it that way
topanga: here they go
yabba_hh: you have no problem with that?
topanga: no I don't
yabba_hh: excellent, cos otherwise I'd do it for you for free
topanga: they can still paypall me 1 euro if they want
topanga: and I give those euro's to kiva.org
topanga: deal closed
(b) BOPIT will inform you of any updates to the plugin but you will need to come back to this post to download them .... which gives us another opportunity to coerce you into donating to a good cause ![]()
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 16th Jun 2008 in : Techno Babble
In the past I've ranted about "webmasters" and their total failure when it comes to designing websites that are accessible to everyone on the web, and Scott and myself have had many a conversation on the same subject, especially that favourite of "webmasters" called CAPTCHA's. Not only are they 100% pointless because they can be easily broken but they require that humans jump through hoops to prove that they are a human and are impossible for people with certain conditions to solve .... such as dyslexics :
Ask Oxford wrote :
dyslexia
/disleksia/
noun a disorder involving difficulty in learning to read or interpret words, letters, and other symbols.
— DERIVATIVES dyslexic adjective & noun.
— ORIGIN from Greek lexis "speech" ( apparently by confusion of Greek legein "to speak" and Latin legere "to read" ).
I single out Dyslexics in particular because I happened to be chatting with Tilqi on IRC about accessibility and the mentality of most "webmasters", the edited version of the conversation went a little like this :
<tilqi> i insist on the impossibility of an absolute globalization / standarization or whatever you call it
<yabba_hh> whilst people think that, you remain correct
<tilqi> when so much obstacle about it
<yabba_hh> the obstacles are 100% man made
<tilqi> i agree the need of it, but like many other things it is both vital and impossible
<tilqi> and you are not very comprimising today (:
<yabba_hh> lol, I'm not compromising on any day when this is the subject, I believe in it passionately
<tilqi> yea but it's like 'world peace' , lol it even sounds funny anymore.. you know it must be established but you can not and never will
<yabba_hh> but you know that it is the right thing
<yabba_hh> accessibility is the same "right thing", and is far more achievable
<yabba_hh> it's only getting "more impossible" because current "webmasters" are making it that way
<tilqi> i mean may be you can do it confiscating all the computers and re distribute and 'locked' computers with firefox installed
<yabba_hh> lol, you need to change the mentality of the coders, not the capabilities of computers
<yabba_hh> I have zero problem with using flash / js ... but things *must* work without both
<tilqi> yea but they mostly *dont*
<tilqi> sector leader websites
<yabba_hh> then that's a failure of coding
<tilqi> all the portals in the world
<tilqi> and nba.com uefa.com etc etc
<tilqi> all use flash %90
<yabba_hh> the fact that they use all this stuff doesn't make it right, it's crap coding and excludes a large percentage of web users
<tilqi> there are countries below %90-99 literacy percantage still
<tilqi> and i am not talking about African countries
<yabba_hh> pretty sure that UK is below 90% literacy
<yabba_hh> and that's without taking into account blind people and dyslexics
That sparked off a google search, where I found this site beingdyslexic.co.uk, not that it was that hard to find, it was the top result in a google search for "dyslexic forum". They have a really cool quote on their home page :
beingdyslexic.co.uk wrote :
At Being Dyslexic with have a strong sense of community built upon the ethos that dyslexia is a gift.
Becuase dyslexia has a right brain dominance, this allows you to see every day activities from a slightly different angle. Dyslexics tend to be more creative and inspirational than your average joe.
Our brains are amazing. Try to learn stratagies that help you overcome any day-to-day problems, this will then allow you to explore the world in our unique but amazing way.
Now these people sound like they really know what they're talking about huh? Sooooo you'd expect that their forums, out of all of the forums in the world would be as dyslexic friendly as possible right? Well they pretty much are, low on images, high on text content and lots of other dyslexic members that are eager to help and share, assuming they can register of course. If you click that link and then agree to their terms and conditions and proceed to the next page, guess what you get to see? That's right a bloody CAPTCHA. Misunderstanding your target audience when you run most sites is bad enough, but whoever made the decision to implement a captcha on a dyslexics site should be put against a wall and shot for total stupidity ![]()
If you use captchas on your own site, whether they're targeted at visually impaired people or not, then I'd advise you put them in the bin where they belong, not only are they a complete waste of time they lock a lot of the web away from people who do not have the ability to complete them ... ohhh, and before anybody mutters anything about audio captchas, don't, there should be no hoops for humans to jump through just to be able to use the web, period.
¥