1 eagleg33k Mar 20, 2009 16:11
3 sam2kb Mar 20, 2009 18:05
If you create a widget/plugin (not a hack) use this code
'tcolor' => array(
'label' => $this->T_('Tag color'),
'size' => 6,
'defaultvalue' => '2b0e02',
'note' => $this->T_('6 character hex color value'),
'valid_pattern' => array( 'pattern' => '~^([0-9a-f]{3}){1,2}$~i', 'error' => $this->T_( 'Please enter a valid hexadecimal number for the background colour' ) ),
),
4 edb Mar 20, 2009 18:12
Wow "valid_pattern" looks freakin awesome. I'm gonna have to start peaking inside some of your plugins to ... uh ... well yeah to steal the cool stuff you take advantage of :D
But actually you should say "if you create a plugin" because if you create a direct widget then you need to hack core files to get it known of.
5 sam2kb Mar 20, 2009 18:22
EdB wrote:
Wow "valid_pattern" looks freakin awesome. I'm gonna have to start peaking inside some of your plugins to ... uh ... well yeah to steal the cool stuff you take advantage of :D
The code was stolen from one of Yabba's plugins :)
But actually you should say "if you create a plugin" because if you create a direct widget then you need to hack core files to get it known of.
We can use the same code for plugins and "direct widgets" added to inc/widgets/widgets directory ;), so this snippet should work in either way.
6 yabba Mar 20, 2009 18:31
sam2kb wrote:
EdB wrote:
Wow "valid_pattern" looks freakin awesome. I'm gonna have to start peaking inside some of your plugins to ... uh ... well yeah to steal the cool stuff you take advantage of :D
The code was stolen from one of Yabba's plugins :)
Buggered if I can remember where I stole it from :-S
¥
7 edb Mar 20, 2009 19:00
sam2kb wrote:
... We can use the same code for plugins and "direct widgets" ...
Yeah yeah that's cool! It's just that a "widget making plugin" doesn't need any hacks. So if someone makes a "direct widget" then hacking has to happen. So "widget/plugin (not hack)" is a bit misleading.
EagleG33k are you following this? Hopefully when you say you've got a widget that's more or less working you really mean you've got a widget-making-plugin that's more or less working. Unless you don't plan on sharing it, but actually you can share a direct widget ... just include the directions for hacking is all.
Hacking the core can be very rewarding ... until upgrade time happens.
8 eagleg33k Mar 21, 2009 01:50
Thanks guys - this has been really helpful. Yes - I have been making it as a plugin. I've been trying to come up with a plugin for Google Friend Connect so that our friends using Blogger can "follow" our blogs. Once I fix a few more things I'll put it up.
This is my first attempt at writing anything for b2evolution, so hopefully it all goes well from here on out. valid_pattern has worked really well - btw.
Thanks again!
Hi EagleG33k. Welcome to the forums. Did you directly create a widget that you hack core files to have b2evolution know about, or a plugin that creates a widget?
If the first case, I dunno.
If the second case, use a $this->msg in your plugin to stop it from going forward.
This assumes you check if it is 6 digits, and know that it is not.