Skip directly to content

Drupal 7

Text formats...

on Tuesday, 28th June 2011 - 0:02

WHY did it take me so long to see something so obvious? 

In Drupal 7, you can change the order in which text formats are processed.  So as an Admin, you don't have to change the text format in your WYSIWYG text editor every time you use it.  I didn't realize this until I watched Kevin Reynen giving his talk on Media in D7 at D4DBoston 2011.  He very casually went through a D7 installation and proceeded to click on

'Configuration' --> 'Text Formats' --> click on 'Full HTML' and drag and drop it to the top of the list. 

Keep in mind, Full HTML is usually only accessible to Admins (and should not be accessible to all).  On my site, I have 'Filtered HTML' set up properly so that I avoid the security risk of using Full HTML.

Now, when I compose a blog post, I no longer have to worry about what the text format is and missing formatting. 

Big Hurrah!

The saga continues... sFTP and Drupal 7

on Wednesday, 22nd June 2011 - 20:27

For updating Core - as stipulated in the previous post - even IF you have a great backup system... you may be stuck waiting 4 hours for your admin to get around to restoring your demolished directories.  My next attempt, I renamed my heavy 'sites' directory to 'zzz' or something of that order and then proceeded to delete the contents of the core directory I had access to.  Then using CyberDuck I copied over the contents of my D7.2 directory and returned my sites directory to its previous state. 

I realised that when updating Drupal 7 (copying all files to your working directory using the likes of CyberDuck) - you need to make sure that you copy the .htaccess file which is hidden on most computers by default (there's also a .gitignore file in D7.2). 

To view the hidden files on a Mac -- open a terminal and type in "defaults write com.apple.finder AppleShowAllFiles -bool true".  You will then need to log in and then log out to reset Finder.  (Ref: http://guides.macrumors.com/Viewing_hidden_files_on_a_Mac, to turn off again replace 'true' with 'false').


In the event of a white screen...(of Death!)

Type the following on the third line of your index.php file.

Echo "Blah"; 

If you see the word "Blah" appear on your site - you know that PHP is working and you've got an internal Drupal problem (not the server, or permissions, etc etc).

What next?  Slow and steady... I plodded along.

Check if your administration pages are working.  I had the interesting case where my frontpage was not working but everything else was!  Knowing that my modules were not up to date - my first job was to update them and then to disable them one by one until I found the culprit that was breaking my frontpage.  (Re-cap: I was working on a site that I created over six months ago and using a pre-release version of Drupal 7 and associated pre-release modules - Views, Link, Ctools, Biblio, acl, forum_access, field_group, wysiwyg). 

When I went to update my modules - I noticed that Forum_Access now depends on both acl and chain_menu_access.  Because of this new dependency, simply droping the new versions in without downloading and enabling chain_menu_access first would surely mess up things on my site.  I suspect that gem, Drush pm-update, does all of this without me being aware - but given that I have to find the cumbersome manual way of doing things... it was quite the revelation.

I also uninstalled any modules I knew that I was not using, in this case Panels.  Becareful about uninstalling modules since this also deletes any data created by the module.  That is the warning it gives you and when you think about modules like Views - you really don't want to delete some things by accident.

So all of the old modules deleted, all of the new modules downloaded to my computer and copied over via CyberDuck.  I ran the update script.  Victory!  My frontpage is working again!  *Insert little dance of Joy!*  I enabled the modules that I had disabled and was prompted to rebuild permissions (for chain_menu_access).  That done, my frontpage was still working.  Satisfied, I took a break.

... it only took three days (the few hours I had to work on it per day).

The challenge of working with strict admins & The importance of backing up your site!

on Wednesday, 22nd June 2011 - 11:22

"I can only use sFTP?" 

What a challenge I faced trying to update my D7 core (modules are still easy) on a recent site that I created prior to the D7's official release and then neglected for 6 months while on mat-leave.  I created the site using SSH which became unavailable due to a change in policy and our strict systems administrators.  So what's wrong? For one, I've never worked solely with sFTP - simply using it as a file transfer tool and for nothing else.  For two, sFTP is unforgiving and backing up a very heavy 'site's directory can seem like a daunting task if you're unfamiliar with what can and can not be done.  I decided to try it out cold turkey since my webserver backs up hourly and monthly - so reverting to an old version is only dependent on when my admin decides to come back from coffee break to handle the request.  Sufficient to say, this is low on his list of priorities.  

My first attempt left my test-site crippled and deformed.  I realised that I have been utterly spoilt.  

Drupal 7 (latest version 7.2) has a lovely update module that updates your modules for you - taking over from using Drush pm-update in the command line.  This is very nice for the amateur web developer - PROVIDED your server allows for ftp updates which mine does not.  Drush on the other hand is equally simple and allows you to do so much in such a short period of time through the command line - but you're dependent on being able to connect via SSH.  For this website I had neither of the two luxeries.

What to do?

CyberDuck became my best friend.  Unfortunately, curious on-lookers/co-workers looking over my shoulder asking questions and Oops! That precious 'sites' directory finds itself deleted.  Now what?  Wait for the admin to reset the folder to what it was.  Now, why was I an idiot-fool enough not to back up the folder locally?  More importantly, why didn't I mirror my site on my computer and make all the relevant changes there?  As I scratched my head, bit my lip, and meditated on my utter lack of caution... I wondered what tools are out there for someone in my predicament.  

Drupal has a module that can come to my rescue! Backup and Migrate.  I will post again later to say how well it worked.

In the meantime, maybe I'll go buy the admin another coffee and dangle it over his head until I get my files restored. 

Is there any way to display a round image in Drupal?

on Monday, 6th June 2011 - 22:54

What I would like to do is the following. However, its proving to be incredibly tricky in Drupal.

 

<div class="round-image" 
style="
width:200px;
height:200px;
border:1px solid #fff;
-moz-border-radius:200px;
-webkit-border-radius:100px;
background:url(http://d6.ahasaetharu.net/sites/default/files/images/grass.thumbnail.jpg)">
</div>

So in the end, we found how the image is called in Drupal 7 - in this case 'field-blog-image'. Created a file called field--field-blog-image.tpl.php in the theme directory.

<?php?>
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php if (!$label_hidden) : ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item) : ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"
<?php print $item_attributes[$delta]; ?>><?php

      $image_url = image_style_url("thumbnail", $item['#item']['uri']);?>
      <div class="round-image" style="width:200px; float: right; height:200px;
border:0px solid #333333; -moz-border-radius:200px; -webkit-border-radius:200px;
background:url(<?php print $image_url;?>); background-repeat:no-repeat; 
background-position:center; background-size:200px;"></div>
      
      </div>
    <?php endforeach; ?>
  </div>
</div>

Reference: http://api.drupal.org/api/drupal/modules--image--image.module/function/image_style_url/7

Drupal 7 Upgrade

on Thursday, 2nd June 2011 - 9:37

Complete!  Now just waiting for the two sites to be swapped.  I still have to move over my development site blurbs as well as my recipees.  OMG, I really love Drupal 7.  The interface leaves me feeling like I'm driving around in one of the super cars described on TopGear (yes, I watch a lot of TopGear).

New to D7 version of Ahasaetharu.net

  • Follow me links
  • The Mommy Blog (to provide some separation between my 'more' professional versus my second full time job as a new mom)
  • The Cookbook (collection of recipes from around the world) & The Cook's Blog (see link via Cookbook) where I can report on my experiences while posting recipes to the cookbook.

A big thanks to my husband, Scor, for helping me with the upgrade.

The waiting game

on Wednesday, 15th December 2010 - 15:56

This week finally gave in to the overall tiredness of keeping up and am now officially at home awaiting our little one's arrival.  Our due date is fast approaching, just 8 days away.  He's still moving around as though there should be plenty of space. 

I've taken on another D7 project, this time a replacement site for the slaneusa.org website for the Sri Lanka Association of New England.  The new site is far from finished, but slowly getting there.  That will make two D7 sites in total.  It's about time I started revamping this site to D7 as wel!  [As far as the crystal site mentioned in the previous blog post, still waiting on approval.  So it may not be up for months for all I know!]

Understandable - long time, no posts

on Thursday, 9th December 2010 - 11:17

I've been pretty silent these past several weeks.  Many things have happened.  For one, I'm now 38 weeks pregnant and waiting impatiently for the pregnancy to finally come to it's inevitable conclusion.  

In the meantime, I volunteered to re-create our lab's website (http://crystal.harvard.edu) in Drupal 7.  This has taken me about two weeks to handle both public and private parts of the site.  There won't be any major layout changes as this is a functional, serious, academic site BUT I've been exploring some new and cool modules such as the Biblio Module. As well as finding the limitations of Views, Private Files in D7.x, profiles in D7.x, etc.  Means many a bug issue posted which makes hubby Scor very happy.

One question - why bother leaving in redundant things just because they've historically 'been there'?  This would apply to profiles but more importantly, something new like private files is completely useless in absence of an access control module.  D7.x doesn't automatically give you access control functionality and you can get around it by using views while 'hiding' your sensitive fields  BUT this doesn't work for files (which I learnt the long way around).  So I'm still waiting for the ACL module to be up and running.  Might take until I come back from maternity leave.  

I suppose while I play the waiting game I could start working on the D7 version of this site.  Nah... will wait until later on in mat-leave phase.