Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6692927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:55:26+00:00 2026-05-26T05:55:26+00:00

In Drupal 6, my module had this next function which inserted a javascript to

  • 0

In Drupal 6, my module had this next function which inserted a javascript to the footer of the page, but in Drupal 7, stuff have changed. How can I do this next code in drupal 7?

function myfunc_footer()
 {
    if(variable_get('myvar',1) && !drupal_match_path(drupal_get_path_alias($_GET['q']),  
          'admin/*'))
    {
         if ($somevar = variable_get('somevar',''))
             {
        return '<script src="'.$somevar.'" type="text/javascript"></script>';
         }
         else
             {
        drupal_set_message(t('something is wrong.'));
         }
    }
}

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:55:27+00:00Added an answer on May 26, 2026 at 5:55 am

    Nothing in your code has changed from Drupal 6 to 7…all of the functions are valid and if this worked for Drupal 6 there’s no reason it wouldn’t work for Drupal 7.

    I don’t really understand why you’re running drupal_match_path against a path alias though, you should be running that against the router path, not URL path:

    if(variable_get('myvar',1) && !drupal_match_path($_GET['q'], 'admin/*')) {
    

    Try that and see if it fixes your problem, if not could you expand a bit about what error you’re getting?

    EDIT

    Thanks for the update, your second comment below is nearly right, you just need to give the render array a key:

    function myfunc_page_alter(&$page) { 
      $page['page_bottom']['my_extra_element'] = array(
        '#markup' => '<div><h3> testingthisout</h3> </div>', 
        '#weight' => 25
      ); 
    } 
    

    You don’t need to specify '#type' => 'markup' as markup is the default.

    Then make sure your module (the one called myfunc) is definitely installed, and clear the caches. You shouldn’t have any problems from there

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Drupal module page where I am populating a form with a
iam developing a module in Drupal, which needs to have a locking machanism, When
I have a Drupal module which allow regex check of a text field. To
I have created a module that works on a vanilla installation of Drupal but
I'm creating a Drupal module which doesn't necessarily depend on other modules, but could
I have created a drupal module which displays some reporting data. I would like
Drupal Aggregator core module is a useful one but suffers many problems. There are
I have some problem in drupal registration page. I want to change whole user
I'm writing a Drupal module and have run into what should be a trivial
I have a drupal module that requires other files from the web. Is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.