That is awesome! A lot of really big sites are using drupal. I love discovering more sites using it!
- Drupal A User’s Guide (Prentice Hall) (i-programmer.info)
That is awesome! A lot of really big sites are using drupal. I love discovering more sites using it!
So my last post pointed out the problem with making dynamically switching content in drupal 7 with the dynamic queries. Here is how you solve it:
//Adding JQuery from the system to perform the voodoo!
drupal_add_library('system', 'ui.tabs');
drupal_add_js('jQuery(document).ready(function(){jQuery("#some-menu").tabs({ fx: { opacity: "toggle" }});});', 'inline');
//Set the first query...or the query the first time
$setExamplePrepare= db_select('example', 'a');
$setExamplePrepare->leftJoin('example_joiner', 'b', 'a.nid= b.nid');
$setExamplePrepare->fields('a',array('Title'))
//I've changed the conditions and stuff..
->condition('a.somefield',$node->nid,'=')
->distinct()
->orderBy('b.vid');
$example = $setExamplePrepare->execute();
if ($example):
echo '

Image via CrunchBase
So Drupal 7 dynamic queries…love them, and hate them.
I just noticed that if you set execute the query, then use the results in a foreach you can’t reuse that result set in another foreach?! So if you’re looking to make a menu for dynamic content on the page (like a JQuery UI tab switcher dealy…that’s what I’m doing) you evidently can’t use the same query to populate both the ul and the content of each div? Lame.
A long time ago I migrated this blog from Joomla! to Wordpress. Since then its been many other things. Now it is tumblr!
When I mirgrated I worked on a tool to expedite that process. Since then many folks have emailed me out of the blue asking for it. Here it is!
I always promise I’ll revisit this. I will…one day. I may even expand on it to be an any CMS to any CMS migration tool. So you can do Wordpress to Drupal, or Joomla to Drupal, or anything to Drupal ;-) I think that’ll be useful.
….The more I LOVE! it.
The database abstraction layer is truly fantastic! It already was in Drupal 7 but they’ve definately made it more dynamic in 7. Love it! Check out this example where I’m creating a fairly straightforward, but not simple, query. In this query I’m pulling from one table and joining 2 more with all kinds of conditions and ordering logic. I can add or take away very quick without having to mine through a monster query!
$example_prepare = db_select('example', 'a');
$example_prepare->leftJoin('example_one', 'b', 'a.nid = b.nid');
$example_prepare->leftJoin('example_two', 'c', 'c.nid = a.nid');
$example_prepare->fields('a')
->fields('b', array('title','created'))
->fields('c',array('blahblah'))
->condition('a.created',$dateRange['value'],'>=')
->condition('a.created',$dateRange['value'],'<=')
->orderBy('a.created', 'ASC')
->orderBy('c.blahblah')
->orderBy('b.title');
$example = $example_prepare->execute();