Hi. I’m kind of a dummy when it comes to PHP. I’m wanting to place AdSense php ( print adsense_display("468x60");
) within the service links module, just above the service links. …The problem I’m having is that when I try to place the PHP within the module, my site will read, “unexpected error on line ___.” What kind of function do I need to use or how would I slip the code into:
<?php
/* $Id: service_links.module,v 1.2.2.2 2006/05/02 06:30:59 frjo Exp $ */
/**
* @file
* Author: Fredrik Jonsson fredrik at combonet dot se
* A module that adds Digg, del.icio.us, reddit, Technorati etc. links to nodes.
*/
/**
* Implementation of hook_help().
*/
function service_links_help($section) {
switch ($section) {
case 'admin/modules#description':
$output = t('Add Digg, del.icio.us, reddit, Technorati etc. links to nodes.');
break;
case 'admin/settings/service_links':
$output = t('Here you can configure the service links.');
break;
}
return $output;
}
/**
* Implementation of hook_perm().
*/
function service_links_perm() {
return array ('use service links');
}
/**
* Implementation of hook_settings().
*/
function service_links_settings() {
foreach(node_list() as $type) {
$name = node_invoke($type, 'node_name');
$options[$type] = $name;
}
$where_set = form_select(t('Node types to display links for'), 'service_links_node_types', variable_get('service_links_node_types', array()), $options, NULL, 0, TRUE);
$output = form_group(t('Where to show the links'), $where_set);
$show_set = form_checkbox(t('Show del.icio.us link'), 'service_links_show_delicious', 1, variable_get('service_links_show_delicious', 1));
$show_set .= form_checkbox(t('Show Digg link'), 'service_links_show_digg', 1, variable_get('service_links_show_digg', 1));
$show_set .= form_checkbox(t('Show Reddit link'), 'service_links_show_reddit', 1, variable_get('service_links_show_reddit', 1));
$show_set .= form_checkbox(t('Show ma.gnolia.com link'), 'service_links_show_magnoliacom', 1, variable_get('service_links_show_magnoliacom', 0));
$show_set .= form_checkbox(t('Show Newsvine link'), 'service_links_show_newsvine', 1, variable_get('service_links_show_newsvine', 0));
$show_set .= form_checkbox(t('Show Furl link'), 'service_links_show_furl', 1, variable_get('service_links_show_furl', 0));
$show_set .= form_checkbox(t('Show Google link'), 'service_links_show_google', 1, variable_get('service_links_show_google', 0));
$show_set .= form_checkbox(t('Show Yahoo link'), 'service_links_show_yahoo', 1, variable_get('service_links_show_yahoo', 0));
$output .= form_group(t('What bookmark links to show'), $show_set);
$show_set2 .= form_checkbox(t('Show Technorati link'), 'service_links_show_technorati', 1, variable_get('service_links_show_technorati', 1));
$show_set2 .= form_checkbox(t('Show IceRocket link'), 'service_links_show_icerocket', 1, variable_get('service_links_show_icerocket', 0));
$show_set2 .= form_checkbox(t('Show PubSub link'), 'service_links_show_pubsub', 1, variable_get('service_links_show_pubsub', 0));
$output .= form_group(t('What search links to show'), $show_set2);
$how_set = form_select(t('Service links in links'), 'service_links_in_links', variable_get('service_links_in_links', 0), array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')), t('When to display the services in the links section.'));
$how_set .= form_select(t('Service links in nodes'), 'service_links_in_node', variable_get('service_links_in_node', 2), array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')), t('When to display the services after the node text.'));
$how_set .= form_radios(t('Link style'), 'service_links_style', variable_get('service_links_style', 1), array(1 => t('Text links'), 2 => t('Image links'), 3 => t('Image and text links')));
$output .= form_group(t('How to show the links'), $how_set);
return $output;
}
/**
* Implementation of hook_nodeapi().
*/
function service_links_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'view':
$node_type = in_array($node->type, variable_get('service_links_node_types', array()), TRUE);
if ($node_type && user_access('use service links')) {
$url = url("node/$node->nid", NULL, NULL, TRUE);
$title = urlencode($node->title);
switch (variable_get('service_links_in_node', 0)) {
case 1:
if ($teaser) {
$node->teaser .= _service_links_render($url, $title, 'nodeapi');
}
break;
case 2:
if ($page) {
$node->body .= _service_links_render($url, $title, 'nodeapi');
}
break;
case 3:
if ($teaser) {
$node->teaser .= _service_links_render($url, $title, 'nodeapi');
}
elseif ($page) {
$node->body .= _service_links_render($url, $title, 'nodeapi');
}
break;
}
}
break;
}
}
/**
* Implementation of hook_link().
*/
function service_links_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
switch (variable_get('service_links_in_links', 0)) {
case 0:
$show_links = FALSE;
break;
case 1:
$show_links = $teaser ? TRUE : FALSE;
break;
case 2:
$show_links = $teaser ? FALSE : TRUE;
break;
case 3:
$show_links = TRUE;
break;
default:
$show_links = FALSE;
}
$node_type = in_array($node->type, variable_get('service_links_node_types', array()), TRUE);
if ($type == 'node' && $node_type && $show_links && user_access('use service links')) {
$url = url("node/$node->nid", NULL, NULL, TRUE);
$title = urlencode($node->title);
$links = _service_links_render($url, $title);
}
return $links;
}
function _service_links_render($url, $title, $type = NULL) {
$links = array();
if (variable_get('service_links_show_delicious', 0)) {
$links[] = theme('service_links_build_link', t('delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png');
}
if (variable_get('service_links_show_digg', 0)) {
$links[] = theme('service_links_build_link', t('digg'), "http://digg.com/submit?phase=2&url=$url", t('Digg this post on digg.com.'), 'digg.png');
}
if (variable_get('service_links_show_reddit', 0)) {
$links[] = theme('service_links_build_link', t('reddit'), "http://reddit.com/submit?url=$url&title=$title", t('Submit this post on reddit.com.'), 'reddit.png');
}
if (variable_get('service_links_show_magnoliacom', 0)) {
$links[] = theme('service_links_build_link', t('magnoliacom'), "http://ma.gnolia.com/bookmarklet/add?url=$url&title=$title", t('Submit this post on ma.gnolia.com.'), 'magnoliacom.png');
}
if (variable_get('service_links_show_newsvine', 0)) {
$links[] = theme('service_links_build_link', t('newsvine'), "http://www.newsvine.com/_tools/seed&save?u=$url&h=$title", t('Submit this post on newsvine.com.'), 'newsvine.png');
}
if (variable_get('service_links_show_furl', 0)) {
$links[] = theme('service_links_build_link', t('furl'), "http://www.furl.net/storeIt.jsp?u=$url&t=$title", t('Submit this post on furl.net.'), 'furl.png');
}
if (variable_get('service_links_show_google', 0)) {
$links[] = theme('service_links_build_link', t('google'), "http://www.google.com/bookmarks/mark?op=add&bkmk=$url&title=$title", t('Bookmark this post on Google.'), 'google.png');
}
if (variable_get('service_links_show_yahoo', 0)) {
$links[] = theme('service_links_build_link', t('yahoo'), "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=$url&t=$title", t('Bookmark this post on Yahoo.'), 'yahoo.png');
}
if (variable_get('service_links_show_technorati', 0)) {
$links[] = theme('service_links_build_link', t('technorati'), "http://technorati.com/cosmos/search.html?url=$url", t('Search Technorati for links to this post.'), 'technorati.png');
}
if (variable_get('service_links_show_icerocket', 0)) {
$links[] = theme('service_links_build_link', t('icerocket'), "http://blogs.icerocket.com/search?q=$url", t('Search IceRocket for links to this post.'), 'icerocket.png');
}
if (variable_get('service_links_show_pubsub', 0)) {
$links[] = theme('service_links_build_link', t('pubsub'), "http://www.pubsub.com/index.php?q=$url", t('Search PubSub for links to this post.'), 'pubsub.png');
}
// Add your own link by modifing the link below and uncomment it.
//$links[] = theme('service_links_build_link', t('delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png');
if ($type == 'nodeapi') {
$links = theme('service_links_nodeformat', $links);
}
return $links;
}
function theme_service_links_build_link($text, $url, $title, $image) {
switch (variable_get('service_links_style', 1)) {
case 1:
$link = ''. $text .'';
break;
case 2:
$link = '
';
break;
case 3:
$link = '
'. $text .'';
break;
}
return $link;
}
function theme_service_links_nodeformat($links) {
return '
'. t('Bookmark/Search this post with: ') .'
'. theme('links', $links) .'