Archived : Techno Babble

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}

Add fields to your posts

Posted on 13th Jan 2009 in : Plugins & Widgets

kiva.org logo

Sponsored by Topanga @link tenderfeelings.be

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? ;)

On with the Plugin

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.

Displaying the fields

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 ;)

Widget mode

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 :D .... the chances are you'll pretty much just want to slap it in your container of choice and leave the settings at default ;)

Download the plugin

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.

Screenshots

Click a thumb to see the bigger picture

  •  The Write Screen
  •  Plugin Settings
  •  User Settings
  •  Widget Settings

(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 ;)

  • MoodHappy
  • ReadingThe screen
  • Listening toWater ... seriously :|

Protect your blogs

Posted on 4th Dec 2008 in : Plugins & Widgets

I hear you knocking

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 ;)

How does it work?

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 ;)

What happens now?

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,
¥

AM Deluxe Profiles

Posted on 9th Jun 2008 in : Plugins & Widgets

Extend your users profiles

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

Admin settings

Allow Avatars
This one's pretty self explanatory, untick it and the ability to use avatars is removed
Guest Avatar
This needs to be the full url to an image to use for guests ( note : this one is not auto-resized, so make sure you upload an appropriate sized image ;) ). Leave this blank to disable guest avatars
Guests
This setting allows you to control if guests can view members profiles, it defaults to "no". Note : this only works if you have an appropriate _profile.disp.php, a sample one is included in teh download. If you don't have an appropriate one then the normal evo action of showing the "edit profile" is shown, which bars guests anyway ;)
Allow Signature
This is another self-explanatory one, untick it and signatures are disabled ;) Note : Signatures will be stripped of any html
Renderers
This is a list of plugin codes that you want to be used to render the signatures, one per line. The default is to use the smilies, bbcode, code highlighter and auto-p plugins, but you can add any that you like. Note : The bbcode plugin will use the post replacements not the comments, this is to enable you to allow urls and images and stuff without getting bitch slapped in your comments by spammers ;)
Timezone
This is the default offset ( in minutes ) from the servers current time, which is handily displayed in the notes field
Time format
This is the default time format to use, meander over top php.net for the various settings you can use
Date format
Uncannily this is the default date format to use, and once again you should hit the php.net link for available settings

New Profile settings and how to use them in your skin

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 ;)

Avatar
If enabled this will allow the users to select an avatar. They need to upload a file called avatar.jpg or avatar.gif or avatar.png or all 3 if they like to their user directory. The avatar will automatically be resized to 80px x 80px or summat. The user can choose any of the three images to use
Skin call ( default parameters shown ):

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
    );
?>
Signature
If enabled this allows users to slap in the signature of their choice. This will be rendered with the plugins that you slapped in the admin setting after any html has been stripped
Skin call ( default parameters shown ):

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
    );
?>
Location
This allows users to type in a witty location like at my bloody keyboard huh?. This is text only, any html will be stripped
Skin call ( default parameters shown ):

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
    );
?>
Timezone, Time format, Date format
This is exactly the same as the admin version and allows the user to see all dates and times in the format of their choice and in their local time. This one is a tad more complicated in your skin
Skin call ( default parameters shown ):

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
    );
?>
You also need to pass the date-time that you wish to convert.

PHP:

// for $Item use :
        'localdatetime' => $Item->get'datecreated' );
// for comments use
        'localdatetime' => $Comment->get'date' );

An alternative method

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 :p

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_mergearray(
                '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 ? :roll: 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"
    ) );
    ?>

and finally, displaying profiles

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

Did I mention hooks for other plugins?

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 ;)

¥

Playing with external links

Posted on 16th May 2008 in : Plugins & Widgets

External links are a pane

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 ;)

¥

Tidying the Admin screen

Posted on 12th May 2008 in : Plugins & Widgets

Does your admin look bloated?

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 :roll:

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.

¥

Predicting tags

Posted on 21st Apr 2008 in : Plugins & Widgets

Auto-complete your tags

I decided to have another play with tags as I tend to use them quite a bit on my posts and I'm always forgetting which ones I've used before and which ones I haven't. So I threw together a plugin that will auto-suggest tags based on ones that you've used in the past. It'll also show you a list of all other similar tags in case you have more than one tag with the same starting letter(s) although they're not clickable at the moment because I haven't got that far.

Installation is pretty simple, just download the zip ( AM AutoTags ), upload it, install it, then meander into the plugin settings and set the tag separator for whatever your version uses. That's it. Now when you enter tags you it should try and auto complete them for you and show you a list of other tags.

NOTE : I've only tested this in FireFox as my IE is having a crisis of confidence when it comes to running javascript, so if you use IE and it doesn't work then tough shit. Also, this is a pre-release version so it's bound to have a few quirks, if you find any then just let me know and I'll see what I can do to eradicate them.

¥

*edit* 24th April
I think I've finally managed to convince IE that it can actually understand javascript so this should now work in IE as well, zip file updated

Page archived : 9th Nov 2009
 

X