Hello, i am running drupal 6.14 with views 6.2.6 and would like to display fivestar voting results in a block. There is a default view called top_content that has exactly what i need, except the results are displayed in a page instead of block. Is there a way to convert the page view to a block view? Thanks in advance.


Sunshiney’s picture

I am a learner like you but I've been living inside views for some time now. If top_content provides a default view, then those settings should be the default when you click within views on the block setting. So, couldn't one just add the block display to the default view and then adjust as needed for the block?

zuessh’s picture

Thanks for the reply, however i'm not sure i understand exactly. The view is not of the type 'block' it is a 'page' type. I need to convert it to a block if possible. am i just missing something in the view setup that tells it to be a page instead of a block?

Sunshiney’s picture

In the left column of the View work area, it should say Defaults, Page, Add Display. Page should have a drop-down selection menu. Click the arrow and you'll see the list: Attachment, Block, Content Pane, Date Browser, Feed, Page. Click on block. Click 'Add Display' That gives you a block view. The block view will display the settings established in the default view. You may modify those but be very careful to use "over-ride" not update default. If you do the latter, you will change the settings in all displays, as you will be changing the default settings. Just look at the page settings and I'm supposing you can use those in your block display. Now, keep in mind that I have not looked at the module you are using. Just going on my experiences...

khosman’s picture

This worked for me - but use it at your own risk and make backups! I haven't encountered bugs from my tinkering - but they may be there:

1) Export your view in order to make a backup copy (!!!)
2) Import, creating a new view, pasting that same view you just used to make your backup
3) Rename it with something reminiscent of the original view, the one you're altering
4) Before saving that new view, do a search on that page for the text containing the name of the block or page you're converting (into page or block)
5) In the line of code that begins "$handler" and contains the name of the page/block you're changing, change that
first argument from "page" to "block" or vice-versa.
6) Save the view
7) Test it out, kick the tires. If it works, delete (after saving a back up!) the old file and rename the new as appropriate

Again - this worked for me five minutes ago - but I haven't had time to see if it causes the world to end - but so far so good. I converted a page to a block this way and the block does show up on the "blocks" admin page and correctly appears where that block is now called for. Note that reversing the process (converting from block to page) might bring about unintended consequences; I didn't try, so I can't say. If those more versed in the Drupal arts believe this to be the wrong way to accomplish this task, please post accordingly.

sokrplare’s picture

Worked for me - only addition I made was to also delete the 'path' and menu link options with the page URL. Might not have been necessary though as Views may just discard that data since it wouldn't apply for a block.

johnatasJMO’s picture

If you have more than one block, it needs to change to "Block_1" and so on...

$handler = $view->new_display('block', 'MyCustomNamedBlock', 'block');
$handler = $view->new_display('block', 'MyCustomNamedBlock', 'block_1');
$handler = $view->new_display('block', 'MyCustomNamedBlock', 'block_2');