The title basically says it all, but just to sum it up again. I want to have polls on my front page and I want anonymous users to be able to vote, but I really don't want the "old polls" link at the bottom of the poll. I do not want users to be able to go back and see the previous polls. Is this a CSS change or did I miss something in the setup of the poll?

Oh, and while I am at it. Does anyone know how to remove or better yet change the title of the poll? By default it is just "poll". I would like it to say something different or maybe even a graphic. Any help would be appreciated!

Thanks a lot,

Luke

Comments

halloffame’s picture

Yeah anyone? I also want to get rid of that link or change it to something else... Thanks...

Road Runner’s picture

I think this is done in block config. Add the title you want to appear in the title space. That said it still doesn't change the title when you click to look at full page - reverts back to just Poll

chris.lord’s picture

title of poll you change it in blocks, find the block 'most recent polls' configure and change it to whatever you want!

Not sure about the link tho...

halloffame’s picture

Yeah thats the way to change the title. But how about the 'older polls' link?

ivanhwg’s picture

in your /modules/poll directory

file poll.module

comment out this line:

// $links[] = array('title' => t('Older polls'), 'href' => 'poll', 'attributes' => array('title' => t('View the list of polls on this site.')));

that's it.

sharlak’s picture

Although your solution works, it is not the best way. When you update your core you are overriding the file you have changed, so your modification will be lost.

To solve this problem I recommend you to upload poll-results.tpl.php and poll-results-block.tpl.php (which are in /modules/poll directory) to your theme folder. There you can change them (removing the links div in poll-results-block.tpl.php, for example).

And remember, you should never modify a Drupal core files if you don't want to lose your changes in the future.

anjjriit’s picture

After more than 1 year, would you tell me how to remove it in poll-results.tpl.php and poll-results-block.tpl.php ?

dragan_r’s picture

Remove the line:

<div class="links"><?php print $links; ?></div>

from modules/poll/poll-results-block.tpl.php

This solution works but it is not so good, because you must be carefull when update your core.

sharlak’s picture

Sorry for answering so late... Although commenting out links line should work as dragan_r said it is not recommended to hack drupal core files (if you update your core you override those files, so changes will be lost). The easiest way to remove the old polls link, should be: copy the files you want to modify to your theme root directory (drupal_home/sites/all/your_theme) and modify them there (comment out links line).

alisamar’s picture


function YOURTHEME_links($links, $attributes = array('class' => 'links')) {

  global $language;
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;
	  
	  if ($link['title'] == 'Older polls') {
		unset($link);
	  }
	  
      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
          && (empty($link['language']) || $link['language']->language == $language->language)) {
        $class .= ' active';
      }
      
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $op = array(
         'attributes' => array(
         'class' => $class),
        'html' => TRUE,
        );
        $link['title'] = $link['title'] = '<span class="'.$key.'">' . check_plain($link['title']) . '</span>';
        $output .= l($link['title'], $link['href'], $op);
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
      }
      $i++;
      $output .= "</li>\n";
    }
    $output .= '</ul>';
  }
  return $output;
}
boftx’s picture

Where do you put the above code?

Also, how do you turn the poll title in the block into a link to the poll page?

tempo22’s picture

All the solution above only explain how to get rid of the links in the result block.

Is it possible to remove then without hacking into the module ?

After some search i saw that in the function poll_block_latest_poll_view of poll.module ( in drupal 7 )
the links are added that way :

  $links = array();
  $links[] = array('title' => t('Older polls'), 'href' => 'poll', 'attributes' => array('title' => t('View the list of polls on this site.')));
  if ($node->allowvotes) {
    $links[] = array('title' => t('Results'), 'href' => 'node/' . $node->nid . '/results', 'attributes' => array('title' => t('View the current poll results.')));
  }
  $node->links = $links; 
wranvaud’s picture

Considering the code above you just have to replace the last line with

$node->links = FALSE;

I could not find a way to do this without changing core files. The function poll_block_latest_poll_view puts the $links variable inside $node. I guess that in this case the only way not to output links is to set it to false before it gets into $node... in the core files.

rooby’s picture

The solution without hacking is this (hacking core is BAD):

<?php
/**
 * Implements hook_block_view_MODULE_DELTA_alter().
 *
 * Remove the links from the poll block.
 */
function MYMODULE_block_view_poll_recent_alter(&$data, $block) {
  if (isset($data['content']['links'])) {
    unset($data['content']['links']);
  }
}
?>

And you can override poll-results--block.tpl.php for the links on the results block.

Anonymous’s picture

Thanks :)

batigolix’s picture

if (in D7) you only want to remove the "Older polls" links and leave the "results" link, use:

function adhesive_tape_block_view_poll_recent_alter(&$data, $block) {
  if (isset($data['content']['links'])) {
    unset($data['content']['links']['#links'][0]);
  }
}
batigolix’s picture

unfortunately when the poll has been submitted the link becomes part of the full complete html output inside $data['content']['#markup'] :(

sebby’s picture

Thanks @rooby for the tip.

This hook hook_block_view_MODULE_DELTA_alter() is vey useful for my current bug.
:)

http://api.drupal.org/api/drupal/modules%21block%21block.api.php/functio...

knalstaaf’s picture

What about squeezing a tad more configuration options in the module? Wouldn't save a lot of time?

rooby’s picture

This is not the right place for feature requests, so nothing will happen from asking here.

You need to post a feature request in the issue queue for the module.
In this case drupal core.

LeMale’s picture

In D7, How can we remove the "older polls" and the votes count on the result bloc?

jenlampton’s picture

If you want to get rid of the links on the results block you can override a special subset of theme_links like this:

/**
 * Overrides theme_links() for the poll results block.
 */
function mytheme_links__poll_results() {
  return '';
}

But it will still leave the surrounding links div.

jenlampton’s picture

This is what I did too but it doesn't work for the results block, only the poll itself. For the results you'll have to also override theme_links() like so:

/**
 * Overrides theme_links() for the poll results block.
 */
function mytheme_links__poll_results() {
  return '';
}

It will still leave the surrounding links div.

scoutex’s picture

Thanks, @rooby 

ashrafabed’s picture

in Drupal 7 to use this block/panel without displaying the 'older polls' link I:
-------------------------------------
- Created a new View (Content pane)
- format Unformatted list
--Show: Rendered Entity - Full Node

Filter
- Content: Type = Poll

Sort
- Post Date

Allow Settings: Some
- Check Link to view, More link, Path override, Title override, Use exposed widgets.... +- whatever you feel like. it makes those options available from the panel pages if you're using panels.

Pager
- Display a specified number (1)
-------------------------------------
I also have comments and printer friendly and display author disabled for polls.... this method worked well for me without any coding

I teach live project-based Drupal Training courses at Debug Academy.

I provide performant affordable Drupal hosting for smaller sites with automatic upgrades at Drupito.

jaap76’s picture

This is a creative way.

b.c.’s picture

Note you may also need to clear cache after updating template files at admin/config/development/performance

contra’s picture

I simply added this CSS code to my style.css file, which makes all the links on the polls (and only those links) disappear:

.block-poll>.content>.links { /* Disable display of links under a poll */
	display:none;
}
frozen10’s picture

You can also copy the "poll-results--block.tpl.php from the poll module and copy it into your theme folder. From there you can remove or comment out the
div class="links"> print $links;

and that should do the job as well. That way you won't be overriding core.

TGEink’s picture

Worked like a charm.

tsaks’s picture

Another method I just discovered is if you have the String Overrides module installed you can enter 'Older polls' and then leave the replacement string blank, and the Older polls link will not appear.