Mouse Posted March 14, 2008 Share Posted March 14, 2008 This code is for a Drupal module i am playing with. i need to get span tags around the <strong>$anchor_text</strong> I have tried every thing i can think of to do it but i have run out of ideas! could someone help me put here? return '<div class="buymeabeer"><span>'. $link .'</span></div>'; almost works but it puts the taggs arround everything and my CSS just wont play nice like that! <?php function buymeabeer_paypal_link() { $paypal_mail = variable_get('buymeabeer_paypal_mail', ''); $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT); $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT); $href = "https://www.paypal.com/cgi-bin/webscr"; $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text"; return l($anchor_text, $href, array('class' => 'buymeabeer-link', 'title' => $title_text), $query, NULL, TRUE, FALSE); } /** * theme function for link display */ function theme_buymeabeer_link() { $link = buymeabeer_paypal_link(); return '<div class="buymeabeer">'. $link .'</div>'; } ?> Quote Link to comment Share on other sites More sharing options...
micah1701 Posted March 14, 2008 Share Posted March 14, 2008 without see the rest of your object, i'm not sure if this would work, but did you try: return l("<span>".$anchor_text."</span>", $href, array('class' => 'buymeabeer-link', 'title' => $title_text), $query, NULL, TRUE, FALSE); Quote Link to comment Share on other sites More sharing options...
Mouse Posted March 14, 2008 Author Share Posted March 14, 2008 Sorry no it just returns "<span>If you like this site please donate to support it.</span>" on the page but thanks! Quote Link to comment Share on other sites More sharing options...
Mouse Posted March 14, 2008 Author Share Posted March 14, 2008 <?php /** * $Id: buymeabeer.module,v 1.1 2007/05/27 15:34:58 yaph Exp $ * * @file * Author: Ramiro Gómez - http://www.ramiro.org * A Drupal module that allows donations via Paypal to buy beer. */ define('BMAB_ANCHOR_TEXT', t('If you liked this post, buy me a beer.')); define('BMAB_LINK_TITLE_TEXT', t('Donate a beer or two via Paypal.')); /** * Implementation of hook_menu(). */ function buymeabeer_menu($may_cache) { $items = array(); $items[] = array( 'path' => 'admin/settings/buymeabeer', 'title' => t('Buy Me a Beer'), 'description' => t('Enable the node types to display the buy me a beer link, set the paypal e-mail and the anchor text for the link.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('buymeabeer_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM ); return $items; } /** * admin settings for the buymeabeer module */ function buymeabeer_admin_settings() { $form = array(); $form['buymeabeer'] = array( '#type' => 'fieldset', '#title' => 'Buy Me a Beer ' . t('settings'), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['buymeabeer']['buymeabeer_paypal_mail'] = array( '#type' => 'textfield', '#title' => t('Paypal E-mail Addrees'), '#default_value' => variable_get('buymeabeer_paypal_mail', ''), '#size' => 60, '#maxlength' => 60, '#required' => TRUE, '#description' => t('Enter an e-mail address that is enabled to receive paypal payments.') ); $form['buymeabeer']['buymeabeer_anchor_text'] = array( '#type' => 'textfield', '#title' => t('Anchor Text'), '#default_value' => variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT), '#size' => 60, '#maxlength' => 60, '#description' => t('Enter the anchor text for the link.') ); $form['buymeabeer']['buymeabeer_link_title_text'] = array( '#type' => 'textfield', '#title' => t('Link Title Text'), '#default_value' => variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT), '#size' => 60, '#maxlength' => 60, '#description' => t('Enter the title text for the link. This is what is displayed as a tooltip when the cursor is moved over the link. This text is also used as the paypal donation identifier') ); $form['buymeabeer']['buymeabeer_teaser_full_view'] = array( '#type' => 'select', '#title' => t('Display in teaser and/or full view'), '#default_value' => variable_get('buymeabeer_teaser_full_view', 0), '#options' => array(0 => t('Full view'), 1 => t('Teaser'), 2 => t('Teasers and full view')), '#description' => t('When to display the link.'), ); $form['buymeabeer']['buymeabeer_node_types'] = array( '#type' => 'checkboxes', '#title' => t('Node Types'), '#default_value' => variable_get('buymeabeer_node_types', array()), '#options' => node_get_types('names'), '#description' => t('Enable the node types to display the link for.') ); $form['buymeabeer']['buymeabeer_weight'] = array( '#type' => 'select', '#title' => t('Weight'), '#default_value' => variable_get('buymeabeer_weight', 20), '#options' => drupal_map_assoc(range(-20,20)), '#description' => t('Specifies the position of the link. A low weight, e.g. <strong>-20</strong> will display the link above the content and a high weight, e.g. <strong>20</strong> below the content.') ); return system_settings_form($form); } /** * Implementation of hook_nodeapi(). */ function buymeabeer_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { if ($op == 'view') { //Check our node is one of the checked types if(in_array($node->type, variable_get('buymeabeer_node_types', array()), TRUE)) { $display_link = FALSE; switch (variable_get('buymeabeer_teaser_full_view', 0)) { // display in full view only case 0: if (!$a3) { $display_link = TRUE; } break; // display in teaser only case 1: if ($a3) { $display_link = TRUE; } break; // display in full view and teaser case 2: $display_link = TRUE; break; } if($display_link) { $node->content['buymeabeer_ad'] = array( '#value' => theme('buymeabeer_link'), '#weight' => variable_get('buymeabeer_weight', 20) ); } } } } function buymeabeer_paypal_link() { $paypal_mail = variable_get('buymeabeer_paypal_mail', ''); $anchor_text = variable_get('buymeabeer_anchor_text', BMAB_ANCHOR_TEXT); $title_text = variable_get('buymeabeer_link_title_text', BMAB_LINK_TITLE_TEXT); $href = "https://www.paypal.com/cgi-bin/webscr"; $query = "cmd=_xclick&business=$paypal_mail&item_name=$title_text"; return l("<span>".$anchor_text."</span>", $href, array('class' => 'buymeabeer-link', 'title' => $title_text), $query, NULL, TRUE, FALSE); } /** * theme function for link display */ function theme_buymeabeer_link() { $link = buymeabeer_paypal_link(); return '<div class="buymeabeer"><span>'. $link .'</span></div>'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.