Articles in the Web Development Category
PHP, regular expressions »
Problem
I have a ton of date strings in the stupid US style dd/mm/yy format. i.e. 12/24/09 being 24th September 2009. I need to convert them to the UK style dd/mm/yy.
Solution 1
As a string in PHP is really just an array of characters, the simplest fix was to address the individual number characters by their positions within the sting, and rearrange them into the format I wanted:
$d = “12/24/09″;
$d = $d[3].$d[4].”/”.$d[0].$d[1].”/”.$d[6].$d[7];
echo $d; // displays “24/12/19″.
Solution 2
I posted my solution on twitter (@hutchings) and asked for comments and @londonhackspace organiser Jonty came …
Flash »
Problem
I’m doing some freelance Flash development, and it’s been a while. I have just created a dynamic text field that I wanted to fill via actionscript, then fade in via an alpha tween. This wasn’t working, even if I set _alpha = 0 on the movieclip containing the text field.
Solution
You can only set _alpha on a Dynamic Text field if the font has been embeded (with the embed button).
Works now! wohoo! Simple stuff that I’ve known in the past, but forgot.
Joomla!, Windows »
Problem
When trying to add a Plugin, Component or Module in Joomla’s Extension Manager, you might get the following error:
JFolder::create: Could not create directory
Warning! Failed to move file.
Shown here:
This is likely – but not definitely – to be after the site has been moved from location to another, a change of directory, or server.
Solution
When a Component, Plugin or Module is added, the Joomla system attempts to copy the installable zip to a temporary directory, called ‘tmp‘. From there, PHP extracts the files and installs them. The error above usually occurs for …
CSS »
Problem
I’ve just had to convert a photoshop visual to a wordpress template. The designer wanted a bulleted list where the bullets themselves were very close to the list items, and were small dashes. Cross browser support for list item and bullet styling is ropey at best, and to make things perfect I’d have to resort to browser specific styles.
Solution
The solution I think I’ll be using for the rest of my ‘web’ career will be this. JUST FORGET THE BULLET ITEM, and use positioned background images instead.
In the stylesheet, add styles …
Internet Explorer, Tools »
Problem
While doing web development, I frequently need to insert lorem ipsum into a text field or textarea. To do this – bearing in mind that I don’t really like or use bookmarks, too messy – I tend to google “lorem ipsum”, hit lipsum.com, select/copy the block of text, and then return to my form field and paste it.
I wanted a quicker solution, and as I find myself using IE more and more to develop in now (thanks to the excellent ‘Developer Tools’ extension – never thought I’d say that!) my lorem …
Joomla! »
Problem
A coleague wanted to change the default ‘browse’ path that the JCE ‘Image Manager’ and ‘File Browser’ plugins use. By default when you use the plugins, the contents of the ‘Stories’ directory will be displayed. It seems that even if you go into the plugin settings ( under ‘Components > JCE Administration > Plugins > [plugin name]‘ ), and set the ‘File Directory Path’ setting, it still doesn’t change the default path!
Solution
Navigate to Components > JCE Administration > Groups as shown below:
Choose Groups from the main menu…
Then select the group you want …
Joomla!, VirtueMart »
Problem
Just now, I needed to move a website running Joomla 1.5 and VirtueMart 1.1.2 from the development server, to the live web space. After I had moved the data, and the files, and updated the path in Joomla’s ‘configuration.php’ file, it seemed to work ok, but all the links in the VirtueMart Admin area still pointed to my development server.
Solution
After doing a ‘find in files’ for my development server’s name, I found two more paths that need changing in VirtueMart’s own configuration file. This is the file:
/administrator/components/com_virtuemart/virtuemart.cfg.php
The following two paths …
Joomla! »
Problem
In Joomla 1.5, at present, there is no way to set the template applied to an article or category based on the section that article is in. Templates can be set by menu item, but not by the overall section they reside in. This means that if multiple templates are being used, each time a new article is added, changes have to be made to the template setup too – very tedious. All I wanted was to be able to create an article or category, add it to a certain …
WordPress »
Problem
The other day I was trying to type two hypens (–) in a post, and when I saved/published the post, WordPress reformatted the hypens to display as an ‘en dash‘ (–).
More Info: After some searching about, and some helpful info provided in the WordPress Codex, I found out about a WP function called ‘wptexturize’ which is applied each time a post is rendered. The function – which can be found in ‘wp-includes/formatting.php’ – replaces quite a few things, like ™ to ™ etc.
Solution
You could stop this happening a number of …
Joomla! »
Problem
I’m using AcaJoom Plus as a newsletter component for Joomla, on behalf of a client. While testing the component I found that once the “Change your subscription” and “Unsubscribe” links were appended, it messed up my template and styling. The text is surrounded SPAN with a class called ‘subscriptionlink_nws’ applied to it, but there is only so much you can do with styles in the newsletter itself.
Solution
The ”Change your subscription” and “Unsubscribe” links can be found in the file ‘class.jmail.php’ which sits in: [site root]/administrator/components/com_acajoom/classes/.
Open this file and at around line 76 …
Add to My Yahoo!