Wednesday, November 17, 2010

Yahoo IMAP in Outlook 2011

Just getting to grips with Outlook for Mac. Also discovered how to set up Outlook with Yahoo Mail using IMAP. Not sure if it makes a difference but I'm using the paid Yahoo mail service.

Tools > Accounts

Add new mail account - enter [from/reply to] email address and password and clear the 'Configure automatically'

Server info
  • User name (without the @yahoo.com bit)
  • Password (should be from initial dialogue)
  • Incoming server: imap.mail.yahoo.com and check the Use SSL (should default to Port 993)
  • Outgoing server: smtp.mail.yahoo.com and check Override default port and Use SSL; set port to 465

That should be it, although to keep everyone happy, you might want to confirm your account name/password under outgoing server's 'More options'.

I actually have my email address set to something else (a 'lifetime' email forwarding alias) and Yahoo seems pretty happy with that - although that's probably another benefit of paying to use the service.

Thursday, July 01, 2010

Coding Drupal in Dreamweaver CS5

I've used big IDEs in the past: all the Drupal gurus/ninjas/whatever use Eclipse, Netbeans or something way over the top. My big project programming days are well and truly over - kicked the arse out of it over the years in BASIC, Pascal, FORTRAN, CORAL, ADA, Java and C++. When I started using Drupal to build websites, my aim was to avoid touching its underlying language, PHP.  Managed that for 2 years, but recently have had to geek out to do a few cheeky things, either in the theming layer or some simple modules. My knowledge of PHP, jQuery and the Drupal API is pretty minimal, so need the following to write code:
  • Code hints (for PHP, jQuery and the Drupal API)
  • Code colouring (keep life simple)
  • Basic syntax checking (not debugging)
  • Integrated FTP and version control client.
Tried Smultron and TextMate, which are great, but can be a bit limited. With the relaunch of Adobe's Dreamweaver (version CS5) all of the above is now possible, with a load more CMS goodies (see http://www.adobe.com/products/dreamweaver - and there's an intro on lynda.com too). OK, you only get SVN support and no Git, but everything else on my list now works well.

Here's how to set up Dreamweaver:
  1. Find the Dreamweaver configuration files, MMDocumentTypes.xml (on OSX at /Applications/Adobe Dreamweaver CS5/Configuration/DocumentTypes) and Extensions.txt (on OSX at /Applications/Adobe Dreamweaver CS5/Configuration).
  2. In MMDocumentTypes.xml add file extensions to the PHP section (you'll need to scroll through the XML to find it):

    <documenttype file="Default.php" id="PHP_MySQL" internaltype="Dynamic" macfileextension="php,php3,php4,php5,theme,module,engine,inc" servermodel="PHP MySQL" winfileextension="php,php3,php4,php5,theme,module,engine,inc" writebyteordermark="false">
    </documenttype>


  3. In Extensions.txt change the line ending in : All Documents to include MODULE,THEME,ENGINE,INFO,INC,INSTALL and the line ending in : PHP Files and append the following extensions MODULE,INC,THEME,INSTALL
  4. Open Dreamweaver and edit your preferences:
    • Code format: indent with 2 spaces; Tab size to 2
    • File Types/Editors - open .module, .theme, .engine, .info, .inc, .install in code view (add to the list of existing extensions)
  5. Create your site locally and set up in Dreamweaver (Site > Manage sites). Then open any page and it should recognize it's part of a bigger thing.... so go to Site > Site-Specific Code Hints and set the 'Structure' to Drupal. Use the same process to add specific libraries (see following video)
Err... that's it

    Tuesday, May 25, 2010

    Theming Drupal [Node] Links

    I spent ages trawling the internet trying to find easy ways to change the little links that Drupal attaches to each node ('Add new comment') and either remove them, change them to icons or shuffle the order.  Options available include:
    1. Write a custom helper module that implements hook_link_alter()
    2. Make the changes inside the theme's template.php preprocess_node
    3. Overwrite the li a attribute with CSS
    Option #1 just didn't work for me - it kept outputting the updated links in both the links ($links) and the categories ($terms).Option #3 was just bad. So I settled on #2:

    I wanted to create custom icons (rather than text) and remove a few links generated by the Feed API module; I also was using the Add this module and wanted that to be the last link at the bottom of the page. So created some nice icons (I used the wonderful FamFamFam Silk icons and a few custom drawn ones) and added them to the /images directory of my theme.  I then edited the template.php file in my theme and added the following function:

    function mytheme_preprocess_node(&$variables) {
        $patheme = drupal_get_path('theme','mytheme');
        $links = $variables['node']->links;
        global $user;
       
        //Repeat following for each $links item you wish to change
        if($links['comment_add']){
          $links['comment_add']['title'] = theme('image', $patheme.'/images/comments_add.png', t('Add a comment'),t('Add a comment'));
          $links['comment_add']['html'] = true;
        }
       
        //Remove link example: removes link to 'Original Feed' (Feed API)
        unset($links['feedapi_feed']);
       
        //Removes 'Login to post comments' link for anon users
        if (!$user->uid) {
          unset($links['comment_forbidden']);
        }
       
        //Simple way to affect order that links are rendered
        //Move addthis to end of $links
        if( isset($links['addthis']) ) {
          $addthis = $links['addthis'];
          unset($links['addthis']);
          $links = array_merge($links, array('addthis' => $addthis));
        }

        //Reset node template links
        $variables['links'] = theme_links($links, array('class' => 'links'));
    }



    And you should obviously customize accordingly. There's a little more explanation in 'Front End Drupal' (Hogbin/Kafer - Prentice Hall 2009) pp163-165 which I highly recommend. I was also using the Print module and there is advice on customizing the module's icons at http://drupal.org/node/190173#themeicon.

    And this is the end result (Left to right: Add new comment, print-friendly view and 'Add This' button). 

    Tuesday, April 06, 2010

    Creating a Custom 404 (Page Not Found) Page in Drupal

    In the event of an HTTP 404 error ("Page not found") this PHP snippet will render a site search form, but will take keywords from the user's erroneous URL and prepopulate.

    Create a new node (node/add/page), and ensure you can enter PHP code in your page body (check input filters).

    Insert the following code into the body of your new page:


    <p>I'm sorry the page you are looking for cannot be found.</p>
    <div id="error-search-box">
    <?php
    // check that the search module exists and the user has permission to hit the form
    if (module_exists('search') && user_access('search content')) {
    $path = $_REQUEST['destination'];
    $keys = strtolower(preg_replace('/[^a-zA-Z0-9-]+/', ' ', $path));
    print drupal_get_form('search_form', NULL, $keys, 'node', 'Search this site');
    }
    ?>
    </div>


    Save this new page (ideally with a custom URL of your choice: such as /page-not-found) and tweak your CSS accordingly.

    So that Drupal will send users there when HTTP 404 errors are generated, go to admin > settings > error reporting (/admin/settings/error-reporting), and set the default 404 error page to page-not-found (or whatever). (You might want to do a 403 error page while you're here too).

    If the above phases you out, as with all problems Drupal, there's a module for that... the thrifty404 module will do exactly the above, but you'll need to do a bit of cunningness in the Drupal theming layer to customize it.

    And Bob's your aunty's live-in lover..!