2

I am using the Hosting module through Aegir. I created a module with some extra fields such as "site_name," "fields," and "description," which was done successfully. I want to use these fields on a newly created website. I am using this code in the new site:

function silverpack_config_menu() {
  // Create additional primary menu items
  $items = array(
    array('link_path' => '<front>', 'link_title' => t('Home'), 'weight' => 0),
    array('link_path' => 'node/2', 'link_title' =>t(drush_get_option('site_name')), 'weight' => 6),
    array('link_path' => 'node/3', 'link_title' => t('Contact'), 'weight' => 8),
     array('link_path' => 'node/4', 'link_title' => t('Contact US'), 'weight' => 10),
     array('link_path' => 'node/5', 'link_title' => t('Terms & Conditions'), 'weight' => 10),
     );

  foreach ($items as $item) {
    $item += array(
      'mlid' => 0,
      'module' => 'menu',
      'has_children' => 0,
      'options' => array(
        'attributes' => array(
          'title' => '',
        ),
      ),
      'customized' => 1,
      'original_item' => array(
        'link_title' => '',
        'mlid' => 0,
        'plid' => 0,
        'menu_name' => 'primary-links',
        'weight' => 1,
        'link_path' => '',
        'options' => array(),
        'module' => 'menu',
        'expanded' => 0,
        'hidden' => 0,
        'has_children' => 0,
      ),
      'description' => '',
      'expanded' => 0,
      'parent' => 'primary-links:0',
      'hidden' => 0,
      'plid' => 0,
      'menu_name' => 'primary-links',
    );
    menu_link_save($item);
  }


}

Here, I want to use drush_get_option('site_name'). "site_name" is one of the fields I use in Aegir's Hosting module.

Does anybody have an idea on how to do this?

  • i followed these steps groups.drupal.org/node/97039. Still not working – Hitu Bansal Mar 9 '12 at 11:00
  • I don't quite understand why your question is so long. The code doesn't seem relevant to what you are asking? Can you please elaborate, or shorten the question? Is your question simply how to query aegir/hosting/provision for current sites name? – Letharion Mar 10 '12 at 12:58
  • No, i want to use some extra fields like steps in groups.drupal.org/node/97039.but not working here – Hitu Bansal Mar 14 '12 at 4:30
0

I see that you have not returned the $items array before exiting hook_menu. I assume it is a typo, but just incase it is not, you need to insert return $items; before the end of the function.

You need to check whether or not Drupal is able to fetch the value returned by drush_get_option().

Can you check in your hook_init(), the value of drush_get_option()?

Something like the following code should work.

function silverpack_config_init(){
  $test_sitename = drush_get_option('site_name');
  dsm($test_sitename);// Install Devel Module to use dsm()
}

Clear the cache, and refresh twice to see if you receive anything back from Drupal. If it is not returning anything, that means either "site_name" is not registered in your database table, or drush is not getting the context properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.