Drupal 7 "older polls" page theming/templating

I was looking at the output for Drupal’s list of polls (the page that appears at example.com/poll) and thinking that it is frankly a bit cr@p. No page title (though that may just be a Snafu in my theme), no bulleted list (it’s crying out for that) and poor text formatting.

Can I create a custom template, like you can for some other output that doesn’t have a core template? Or, is it a task for the dreaded template.php overrides (which I always hate trying to come up with)?

Sounds like it’s time for someone to start flexing some CSS muscle.

But that cannot do anything to fix the absence of a list element, the absence of a title or the bad text formatting (“I mean, hyphens instead of em dashes? Really, Drupal developers, you should do better”). Sounds like it’s time for someone to start reading posts more carefully. :wink:

Well, then I look forward to your version of this older polls thing … after you perfect it and contribute it. :smiley:

By the way, I believe there should be a file in modules/polls named poll-results–block-tpl.php. Copy that to your theme folder, and you can adjust how poll data is displayed in that template file, if I’m not mistaken (it’s been a while since I’ve used a poll). Also double-check your poll block to make sure the title is published, along with the module’s configuration to make sure you’re not missing something.

poll-results–block-tpl.php is not related to this in the least. This is about output that is not controlled by a template. I can’t make it any clearer.

I don’t know about the whole “can’t be any clearer thing.” You could probably work on that part a little more – no offense. Anyway, assuming we’re talking about the Polls module (which I believe we are), then the templates are where you would control all of the output and how it is to be displayed, from the title to the votes, links … everything is available to you as variables that you decide how to display or whether to display it at all.

Example: " <h1>$title</h1> " would display your title in an h1 tag.

Conversely, “<span style=“color:red;”>$title</span>” would take your title and make it red and and so on and so forth.

If it’s a problem with the data itself, then you could do a template preprocess function (template_preprocess_poll_results()), or modify the module itself.

Unless this is some “special” drupal module that does everything completely different from every other module, which I somehow doubt. :smiley:

I referred specifically in my first post to the

list of polls (the page that appears at example.com/poll).
This page’s output is not altered by templates from the Poll module. I don’t see how I can put it any clearer than I have. Hence asking whether a custom template, such as can be used for theming content that does not have an existing template (e.g. the contact form), would be a solution.

I could give you a lot of suggestions on how you could put it clearer.

For example: “My issue isn’t with how the individual polls are displayed, but how they display as a list, and within that context only. I want control specifically over the list view.”

That would have been much clearer, but that’s neither here nor there. Anyway, if your issue is with how they are viewed as a list, then you should be using VIEWS to put together your list of polls, and this will give you the control over their display that you’re looking for.

Good luck.

Ok, I’m a little late to the game but I don’t really understand what your issue is with Polls. I haven’t had the need for using Polls before but I fired them up on a D7.12 site just to have a look and made a simple Poll to test them out. on my list page (example/poll) the title is where it should be and the polls are listed in a standard unordered list.



<h1 class="page-title">Polls</h1>

<ul><li><a href="/content/what">What is this</a> - 2 votes - open</li></ul>    



I’m pretty sure this is the formatting you wanted and it’s right there out of the box.

That does not reflect at all the output that I get. Take away your H1 and replace your list items with divs and you are closer to what I see. And, even if I could determine why your installation has produced those elements, your example snippet still has the poor text formatting after the anchor that—as far as I am aware—cannot be altered.

Everything that is outputted to the browser can be altered. You can either alter using _ _ _ tpl.php or template.php but that doesn’t explain why you’re getting the results have described.

Something must be broken by your theme or some custom code somewhere. The site I ran my test on is a bare bones D7 installation. It contains zero custom code and I’m running an unadulterated copy of the Taraski theme (http://drupal.org/project/tarski) because I wanted it to look pretty without having to write a theme for it.

Edit: I see your point about the text formatting in the anchor. I think that should be able to be changed via one of the poll template files but if it really bothered me I’d follow CMS_Dude’s lead and make a new list with views so I could fine tune it exacty the way I want it to be.

Just another bit of info on this topic…
It looks to me like the formatting of the polls is in the poll module (/modules/poll/poll.pages.inc) in the function poll_page():


$output = '<ul>';
  foreach ($queried_nodes as $node) {
    $output .= '<li>' . l($node->title, "node/$node->nid") . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
  }
  $output .= '</ul>';

So if I were interested in modifying the markup in the link I would override the function poll_page() with my own themename_poll_page() function in template.php and change the way it outputs the markup.

  • It might be that your theme is already doing that (causing the weird output) if you built your theme based on another like Zen or something.

Thanks, awasson.

Good call. That would also be my guess.

Well, you’d guess wrong then.

So have you figured out where the markup is breaking out of an unordered list?

Yea, I’d like to know, too.

Unless he has a “bootleg copy” of Drupal 7. :smiley: I’m at a loss.

The only other thing I can think of is that there would be a conflict with the javascript in one of his plugins that’s manipulating his unordered lists – but that wouldn’t show if he’s doing “view>source.” But either way, it doesn’t appear to be a problem with core. He would have had an answer by now if his attitude was a little more humble and gracious. He acts like he’s talking with customer support for a product he purchased and he’s demanding answers. I don’t think he gets yet how open source works.

CMS “dude”, I would not normally comment upon other people’s styles, but I think that you have been completely unhelpful here. I was following this thread to see if it had any useful advice (I’ve just built my site with Drupal, and this theme/template thing is not easy to grasp), but all that you have done is tell this person to use CSS to fix things that even I know can’t be fixed with CSS and then belittle him/her for calling you on it. You should be more polite and constructive.

Mat30: the template system is not easy to use, I know (and I’ve had to ask quite a few questions about it here). The only advice that I can give is that you can copy any of the functions that are in the included files and put them in a modified form in the template.php file to over-ride them.

Well, since we’re talking about manners, being polite and constructive, might I suggest the following reply, then:

“Thank you for your reply, CMS Dude, but unfortunately I’ve ruled that one out, and this doesn’t appear to be a CSS issue.”

Would that have been so difficult?

Look, I don’t mean to lecture some of you guys like your Moms or bully you around like your older brothers … but if there’s one piece of advice I could give to you … that is to be gracious and thankful for a reply, regardless of your perceived value of the reply. You will get a lot more help from people that way – always. Ultimately, you will seek out answers in your own way, and hopefully you will be successful with it. But seeing as how it’s been about 3 days since this question was asked, and still no definitive answer … I’m guessing there’s probably a better way of asking for help. :smiley: Good luck on your sites, guys!

I think I’ll jump in here for a minute…

I think it’s difficult to gauge the intent or emotion from written words on the screen and I think that’s why sometimes things can get a little heated on help forums. I’ll add that although I don’t know CMS Dude, I think he’s been very helpful and knowledgeable in many posts I’ve seen. If I were to take a guess, I would guess he was maybe trying to add some levity to the topic seeing as Mat30 was a bit inflamed in his initial posting trashing the core developers at Drupal for something clearly beyond their influence.

Maybe his post (Sounds like it’s time for someone to start flexing some CSS muscle) was a bit cheeky but if Mat30 came back with something like “thanks but that isn’t the issue… The markup is coming out broken, etc…” then they could have moved on and found the solution. Yeah, it gets frustrating working with one of these massive CMS systems when you first get started but if CMS Dude hadn’t answered the initial call for help and I hadn’t happened by, I’m not sure if the post would have been answered at all.

Aside from that, I’m curious about whether Mat30 found a solution to the problem :smiley: