Hi,

I want to add facebook and twitter icons in the footer on my website, so that, when a visitor clicks at facebook icon, he is taken to facebook page of mine and similarly, clicking at twitter will take the user to my twitter page. It is very simple to put static links, but, i want to know is there any module available that allows me to add the account details from backend like my page urls from backend.

Regards,
Kul.

Comments

paul.linney’s picture

Hi Kul,

I done this a while back as a admin configuration page using site variables. It just provides a text field to put the url to the respective social network page.

Create a module and replace YOURMODULE with an appropriate name:

/**
* implementation of hook_help().
*/
function YOURMODULE_help($path, $arg) {
    switch ($path) {
        case 'admin/help#yourmodule':
            return t('yourmodule help');
    }
}

/**
* implementation of hook_menu().
*/
function YOURMODULE_menu() {

  $items = array();
  
  $items['admin/settings/finduson'] = array(
    'title' => 'Find Us On',
    'description' => 'Urls for social media networks',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('YOURMODULE_finduson_admin'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
   ); 

  return $items;
}

function YOURMODULE_finduson_admin() {
    
    $form = array();
    
    /*
    * Find Us On Details
    */
    $finduson = variable_get('finduson', array());
    
    $form['finduson'] = array(
        '#type' => 'fieldset',
        '#title' => t('Find Us On Details'),
        '#tree' => TRUE,
    );
    
    $form['finduson']['twitter'] = array(
        '#type' => 'textfield',
        '#title' => t('Twitter'),
        '#default_value' => $finduson['twitter'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    );
    
    $form['finduson']['facebook'] = array(
        '#type' => 'textfield',
        '#title' => t('Facebook'),
        '#default_value' => $finduson['facebook'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    );
    
    $form['finduson']['vimeo'] = array(
        '#type' => 'textfield',
        '#title' => t('Vimeo'),
        '#default_value' => $finduson['vimeo'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    );
    
    $form['finduson']['linkedin'] = array(
        '#type' => 'textfield',
        '#title' => t('LinkedIn'),
        '#default_value' => $finduson['linkedin'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    );
    
    $form['finduson']['flickr'] = array(
        '#type' => 'textfield',
        '#title' => t('Flickr'),
        '#default_value' => $finduson['flickr'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    );
    
    $form['finduson']['delicious'] = array(
        '#type' => 'textfield',
        '#title' => t('Delicious'),
        '#default_value' => $finduson['delicious'],
        '#size' => 64,
        '#maxlength' => 128,
        '#description' => t("Enter the url for your feed"),
        '#required' => TRUE,
    ); 
    
    return system_settings_form($form);
}

Then in your footer place something similar to this:

<?php
$finduson = variable_get('finduson', array());
?>
<section id="find-us-on">
    <h2>Find us on...</h2>
    <ul id="social-networks">
        <?php if(!empty($finduson['facebook'])){ ?><li id="facebook"><a href="<?php print $finduson['facebook']; ?>" class="external-link" title="Facebook">Facebook</a></li><?php } ?>
        <?php if(!empty($finduson['twitter'])){ ?><li id="twitter"><a href="<?php print $finduson['twitter']; ?>" class="external-link" title="Twitter">Twitter</a></li><?php } ?>
        <?php if(!empty($finduson['linkedin'])){ ?><li id="linkedin"><a href="<?php print $finduson['linkedin']; ?>" class="external-link" title="Linkedin">Linkedin</a></li><?php } ?>
        <?php if(!empty($finduson['vimeo'])){ ?><li id="vimeo"><a href="<?php print $finduson['vimeo']; ?>" class="external-link" title="Vimeo">Vimeo</a></li><?php } ?>
        <?php if(!empty($finduson['centralstation'])){ ?><li id="centralstation"><a href="<?php print $finduson['centralstation']; ?>" class="external-link" title="Central Station">Central Station</a></li><?php } ?>
        <?php if(!empty($finduson['flickr'])){ ?><li id="flickr"><a href="<?php print $finduson['flickr']; ?>" class="external-link" title="Flickr">Flickr</a></li><?php } ?>
        <?php if(!empty($finduson['delicious'])){ ?><li id="delicious"><a href="<?php print $finduson['delicious']; ?>" class="external-link" title="Delicious">Delicious</a></li><?php } ?>
    </ul>
</section>

Hope this helps,
Paul

Paul Linney
Owner & Web Developer

quardz’s picture

kuldeepkaundal’s picture

Thank you guys for your replies, i'll try them!