development (web)

MODx (Evo): Setting up a subnavigation – if there are subpages (children)

| development (web) | One Comment

Wayfinder is a great tool for MODx to automatically display menus and submenus on your website. By default though, it doesn’t handle not displaying the submenu on a subpage if there are no children, so you end up with the title of the page appearing where the menu should be.

So that you can just have one template for subpages, you can use a snippet to check if there are children for that page, and if so display the sub menu.

Here is the code I use.

1. Create a chunk called ‘subnav’

2. Create a snippet called ‘displaySubnav’
documentObject;
if($current['isfolder']=='1'){
$chunkArr = array(); // if you want to parse stuff to the chunk, put it in an array here.
echo $modx->parseChunk('subnav', $chunkArr, '[+', '+]');
}
?>

3. Call the snippet in your template – must be a non-cached call.
[[displaySubnav]]

Now if there are children you’ll see a sub menu, and if there isn’t it will just appear blank.

Three Key Things To Look For In A Web Developer

| business, development (web) | 2 Comments

Web standards, CSS, Upgradable System With thousands of businesses promoting web design and development services, it can be hard to know what to look for. Other than the obvious method of looking at their previous work and deciding if you like their design style, there are many other important factors you should consider. Here is a short list of three key things that you should ensure your web developer has no matter how big or small your project is.

Follows web standards

This is important for a number of reasons. First of all it helps to ensure that your site is accessible to the largest number of users possible. This includes users with disabilities as well as search engines. Secondly, it helps to ensure that your site loads quickly and isn’t padded out with unnecessary code. And thirdly, it helps to ensure that your site is future proof and compatible in a variety of browser and different platforms. With new browsers and internet capable devices (such as the iPhone) coming out every couple of months, you don’t want to have to keep redoing your website every time a new technology comes out.

Uses CSS and not inline styles or table based layouts

CSS allows a developer to separate the design component of a page (for example colours and styles) from the actual content (i.e. the text). By doing this not only is the code cleaner, but it also means that changes to the visual appearance of your site can be done in minutes and are effective throughout every page in your site, instead of having to update each and every file to match. In regards to using tables for layout, not only does this breach web standards, but they also pad out the code of your website making it slower and harder for screen readers and search engines such as Google to read.

System can easily be upgraded as your business needs grow

There’s no point in getting a website developed that you have to redo from scratch 6 months later as your business needs change. Make sure that the system is flexible enough that new features and content can be added as required. This can save you thousands of dollars in the long run.

Using Xampp on Mac for Ruby on Rails

| development (web) | 5 Comments

I recently installed Xampp on my mac to help with some other development work, only to find that my previous install of MySQL which I was using for Ruby on Rails development no longer worked. I was receiving errors:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

and

No such file or directory – /tmp/mysql.sock

To fix the problem, I added the following line to config/database.yml

socket: /Applications/xampp/xamppfiles/var/mysql/mysql.sock

Huge thanks to http://soledadpenades.com/ who had the solution.

Chmod MODx MaxiGallery fix

| development (web) | 8 Comments

MaxiGallery is a customizable image gallery for the PHP application framework/CMS MODx. I have been testing it out locally on a windows based PC running Apache, and came across an error when trying to upload files as per the Picture and Thumbnails walkthrough.

« MODx Parse Error »

MODx encountered the following error while attempting to parse the requested resource:

« PHP Parse Error »
PHP error debug
Error: chmod() [function.chmod]: No such file or directory
Error type/ Nr.: Warning – 2
File: assetssnippetsmaxigallerymaxigallery.php
Line:372
Line 372 source: chmod($mg->path_to_gal.$name,0666);

The fix thanks to doze on the modxcms forums:

Try changing lines 371 – 378 in maxigallery.php from:
Code:

move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $mg->path_to_gal.$name );
chmod($mg->path_to_gal.$name,0666);

$handleMessage = $mg->handleFile($name, $modx->db->getRecordCount($rsx));
if ($handleMessage != “”) {
$manageOuterTplData['messages'] .= $handleMessage;
$upload_error = true;
}

to:
Code:

if(move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $mg->path_to_gal.$name )) {
chmod($mg->path_to_gal.$name,0666);

$handleMessage = $mg->handleFile($name, $modx->db->getRecordCount($rsx));
if ($handleMessage != “”) {
$manageOuterTplData['messages'] .= $handleMessage;
$upload_error = true;
}
}

This worked for me without needing to do the other changes that he mentioned in the post, but if it doesn’t work for you, try checking out the rest of his comments.

Ruby: Displaying current date/time as default in text field

| development (web) | No Comments

This is pretty basic stuff, but I couldn’t easily find the details on how to do it, so here it is for anyone else who is looking for it.

Scenario: I wanted to put the current date and time as the default text for the date field in a form.

The code:

In the form I used:

<p> Date: <br /> <%= f.text_field :date, :value => @current_time %> </p>

And in the controller for the view put:

@current_time = Time.now.strftime(“%Y-%m-%d %H:%M”)

Formatting:

You can change the formatting of the date/time displayed, but I am using this for now as this way it puts it straight into MySQL without me having to rework it.

Additional info:

Refer to: http://au2.php.net/strftime for details on formatting dates using strftime

Bring on the gravatars

| development (web) | 2 Comments

Today I have updated this site with Gravatar so that all you nice folks that leave me comments (you know who you are) can now also include an avatar. Gravatar ( Gloabally Recognized Avatar ) allows you to store an 80 x 80 pixel image on their servers. They even have a nice tool to help you crop your image. Then each time you leave a comment on a gravatar enabled site, it will automatically add your avatar, based on your email address.

Sounds nice, where do i sign up?
To signup, just go to http://site.gravatar.com/signup pop in your email address, upload a picture, and you are ready to go.

Run your own blog and want to add gravatars?
The good team at gravatar have created plugins for most of the popular blogging engines, so just head over to http://site.gravatar.com/site/implement and download the plugin for your site.

Edit (15-08-2007): there appears to be an issue with Gravatar not always displaying pictures. I have taken them down until I can be sure that they are gonna work,  if anyone has any suggestions as to how to resolve this issue, please let me know.