It is really hard to understand why there is no working block with reviews in this module.
Note: "demo" views are not working for me.

Using the attached file (upload to a selected module - here "mymodule") you can implement a sample block with reviews.

Somewhere in any module add:

/**
 * Implementation of hook_block().
 */
function mymodule_block($op = 'list', $delta = 0) {

  if ($op == 'list') {
    $blocks[0]['info'] = t('Custom Reviews: Node Reviews');
    return $blocks;
  }
  else if ($op == 'view') {
    if (user_access('access content')) {
    switch ($delta) {
          case 0:
            include_once dirname(__FILE__).'/custom_review_block.inc.php';
            $block = array(
              'subject' => t('Custom reviews: node reviews'),
              'content' => _custom_review_node_reviews(),
            );
            break;

        }
        return $block;
    }
  }
}
CommentFileSizeAuthor
custom_review_block.inc_.php_.txt1.33 KBvpiotr

Comments

Striky2’s picture

Status: Active » Postponed (maintainer needs more info)

Thx for the comment.

I'll add a default block then, even if this is really nothing compare to what a view embedded in a panel and a proper context can do...
Thank you for the code sample.

However, I have some issues coding a block instead of using a view :
Well, if we think about it, why bother coding my own sql request (checking the reviews, then displaying them) into a block, instead of using the module which is done for that same business, ie: views. So, to a prime approach, I will say this is better for everyone to use views (I do agree on the fact that I can put that in a pre-configured block though, if it is your idea). Of course I can be wrong on that argument but before I start modifying my code, I'd like to know where this is wrong...

What we have to discuss then is: "making a block (ok) but using views (or not using views) to display the reviews..."

Also, could you give me more details on the "not working default view" please. It might only be a version issue (when I supplied code on CVS), because they are working just fine on my own site so...

Thank you

vpiotr’s picture

1. The demo view 'demo_reviews_typed_on_a_node' - when using custom reviews + CCK simply displays a whole list of nodes with no connection with the main one. And what is best the node list does not contain the expected review.

2. Of course views are better then a block, but the demo views are buggy.

3. I personally hate views because they are too complicated, too buggy and difficult to understand. However, if you can prepare a view that does not require any configuration (I mean -any-) then such a view is very helpful.

4. If think there are more people than me that prefer blocks over views.

Striky2’s picture

Status: Postponed (maintainer needs more info) » Fixed

Just for everyone's information, after a last testing, the demo views are working just fine:

Of course, they have to be

  • enabled in the views admin (and maybe a views clear cache won't be bad after that)
  • properly called, because they are views with arguments

The two demo views are called : demo_reviews_on_a_node_type_by and demo_reviews_typed_on_a_node, they are located in the bottom part of the views admin (because automatically generated views, and again, they have to be enabled).

-> demo_reviews_on_a_node_type_by takes two arguments (not working otherwise) : the exact node->type of a reviewed type (lets say books), and the exact uid of the author making the review (let's say 1). Then, going to the URL : http://myurl/custom_reviews/on/books/by/1 : this will create a "blog" of the user 1 reviews on all the books)

-> demo_reviews_typed_on_a_node takes two arguments (not working otherwise) : the exact node->type of a reviewer type (lets say we've create a node type article to make our reviews), and the exact node->type of the node reviewed (let's say books again). Then, going to the URL : http://myurl/custom_reviews/reviewer/article/on/books : this will create a "blog" of all the users having made reviews on books while using your 'article' specific reviewer

Basically, if you compose these two example and if you know a bit of view configuration, you can almost do everything you want as a view result.

============================================================
The support for views will be made for drupal 6.x, however, for now, there will be no support for the hook_block() [for the reviews preview, not for the "add/edit review form which already exists"] won't be done for a very simple reason: if we do that, we are going to make request to the custom_review tables, then we are going to theme the output of these requests, then to remake a sort results form and things like that, and this has already be done by views, in a great manner.
So we should focus on how to make this 100% compliant to views instead of using our own proprietary html output of a request.

vpiotr’s picture

Status: Fixed » Postponed (maintainer needs more info)

Thanks for this clarification, but how these views can be used as blocks, not a separate pages?

Could you explain that using step-by-step approach?

Striky2’s picture

Yep, of course. You are absolutely right, this has to be documented.

I made a specific support on how to make a panel-embedded view of the supplied custom-review views. Is that what you are looking for, (if it's the case, il will post another issue/thread just after that for custom-review, views & panel integration).

If it's about having only a block with the specified view inside, I personally never did this. However, there is this option in the views called "provide views as a block" right? So my guess is

1/ enable the views (provided as default) in the views list
2/ add them (in the views list), so that you can override the default conf of these views
3/ click (on each view config) on 'provide views as a block'.
4/ see if a new block appears in the blocks list.
5/ please check the last readme.txt version, I provided a full documentation on the 2 REQUIRED arguments for each provided view. (If these arguments

are not in the URL, this obviously won't work).
It also means that you will have to make your own view at some point (but starting from the one I've provided, sor the arguments will be easy to find), because the URL of your view in the block won't match with the default URL of your node.

(That's why panel is great, cuz it can send a context as arguments, which basically avoid having this URL issue).

vpiotr’s picture

Yes, I would like to use these views inside a standard block.
I have no idea how to do that using "custom_review" views, but what I have found out recently is that "backlinks" contains a very similar view (unrelated in contents) that works without ANY configuration.

I think this is because of the following line:

  $view->view_args_php = 'if ($type == \'block\' && arg(0) == \'node\' && is_numeric(arg(1)) && arg(2) != \'backlinks\') {
    $args = array(0 => (int)arg(1));
    return $args;
  }';

but this is only a blind guess.
Is it possible to include in "custom_review" views a similar solution?

Striky2’s picture

Could you give me a pointer on the original post please? I think I see where it leads, but I need more info on the code you brought here, which seems promessing though.

vpiotr’s picture

You mean where is the code?
Right here: http://drupal.org/project/backlinks