I've got a Panels node override for an Organic Group content type, and the content of the panel contains a views content pane that shows the member nodes of the current group. All of this works well, including paging.

I'm trying to create a block that would allow me to have a "Blog Archive" type view for each group, but I can't figure out how to pass the date argument into the main view.

I've gotten the date summary view to work, and the correct months show up in the block, but it can't detect the current page. I'm guessing that might be an issue with the Date module, but even when I hard-code a path and the links have the month in them, I'm not sure how to pass them into the main view.

I got it sort of working by providing a PHP default argument in the view (return $_GET['date']) and the URL arguments work, but then when one isn't provided the view returns nothing instead of the normal descending list of nodes. It seems like it might work if I could get a context argument out of a named URL query parameter, but that isn't available. And even then I'm guessing the pager might wipe the argument out.

Any ideas? Is this even possible?

Comments

merlinofchaos’s picture

Status: Active » Fixed

In your view, the argument should have a select box for "Action to take if filter value does not validate".

Set this to "Display a summary". One downside here is that it's not completely replicating the list that's available for no filter value, and I only just now saw this. This may be a bit of an error from the update, but my hope is that it will take the same values. Anyway, give that a try -- if your PHP argument code returns NULL, NULL will never validate, and it will take this action.

If you can't make that work, then this will have to change to a bug report.

karlshea’s picture

Well I have that part working, sort of. I think I'm not really being clear on what I'm trying to do, or at least where the problem lies:

I have two content types, Blog landing and Blog entry. Blog landing is a OG Group, and Blog entry is OG content.

There's a Views Content Pane display that shows all of the Blog entry content for the given Blog landing, and that pane is embedded in the Blog landing content type through the Panels node display page. That is all working fine.

Additionally, I have another separate view with a Block display, which I'm trying to show the month summary view in. This is also working, in the sense that it is showing the list of months that have content for the currently-shown OG Group.

These are the two problems:

  1. The links that the summary view block generates are empty (href="") unless I add a value to "Base path" in the year+month contextual filter, then they are filled in (href="/test/1/2001107"). I'm not really sure where this is falling down, maybe it's not finding the path or something. Possibly this is a bug in Date.
  2. Most importantly, I can't figure out how to get the Views Content Pane to accept or find an argument in the URL while it's embedded in a Panel.

Somehow I'd like to make it so that clicking one of the months in the archive display will filter the view inside the panel will actually filter that view.

I was trying to expose filters or use URL arguments, and my plan was to write some JavaScript that would handle a click event on that Archive Block link and tie it all together. But I'm stuck on how to get that value into the view in the panel. The pager works, but exposed filters don't and I couldn't find another method to make it work either.

I can attach any exports that you think might help if I'm still not quite explaining this right :-)

karlshea’s picture

Status: Fixed » Active
ewills’s picture

Status: Active » Closed (fixed)

Pretty sure I understand what you mean - I had this problem.

To fix it, in the edit view window for the content pane, under pane settings you need to set the "Argument input" field. There's lots of different options here, but to get the pane to behave in the same way as a block, select "From context".

Hope that helps!

Edwin

karlshea’s picture

Title: Filtering Views Content Pane » Passing arguments from a block or URL to a Views Content Pane
Status: Closed (fixed) » Active

There's lots of different options here, but to get the pane to behave in the same way as a block, select "From context".

There are indeed lots of options there, but none that I could find that seem to get any arguments from the URL.

I changed the title to hopefully be more clear on what I'm trying to do.

karlshea’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 7.x-3.x-dev » 7.x-1.x-dev
Component: Panel nodes » Views Content

Also moving this to the Ctools Views Content queue, I'm guessing this issue doesn't really have anything to do with Panels.

karlshea’s picture

Status: Active » Closed (fixed)

Found a different way to do it, closing.

kclarkson’s picture

@Karl,

Could you post how you did your argument?

Thanks

karlshea’s picture

Make sure you have "Use panel path" in your view pane settings, which will get some of the paths working. It's still pretty weird however. We changed some of how we wanted things to work, since this isn't really working well.

karlshea’s picture

Title: Passing arguments from a block or URL to a Views Content Pane » Views Content Pane can't get argument from URL when inside a Panel
Status: Closed (fixed) » Active

I'm reopening this because I still don't see a way to pass any arguments.

The distilled issue is this: Views Content Panes can't get an argument from the URL when they are inside of a Panel.

If I add a "Content Created year + month" context to a content pane, there isn't any way for that value to come from the URL. Maybe this is intended, but it doesn't allow for filters of OG content from a Panels-overridden OG group node.

heatherwoz’s picture

I'm having a similar issue. I've got a content type set to display as a two column panel, with one views content pane in each column. I want the content panes to inherit the arguments from URL, and I can't figure out how to pass them.

I have the filter set to Provide default value > Raw value from URL and it works when I enter contextual filters in the views preview, but not when I'm viewing the content type itself. I feel like there must be some way to pass these arguments but I'm just missing it.

heatherwoz’s picture

A little more experimenting and I figured it out. As #4 posted, the solution was in the Argument input field. In my scenario, the context is the node being viewed. And the URL arguments I wanted happen to correspond to field values on the node. So I was able to set the Argument input to From context and the Required context to the specific field on the node. You could pass Created date or other properties of the node this way as well.

karlshea’s picture

Well, it will work as long as the node has the values that you're trying to filter on. We wanted to filter by a list of months, which still wouldn't work.

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Ok, I think I see the base problem.

When describing this, you need to be clear that you're using a page manager page that does not give you control over the URL.

For example a standard page manager page allows you to enter the url: 'foo/%/%' for example. That allows you to then add arguments which turn those URL elements into contexts. So when you say "get arguments from the URL" that is exactly what that does and what I assume people are using.

However, if you're using a system page, such as node_view, you do not have control over the URL. If someone visits node/1/foo you do not have access to the 'foo'. Am I correct in believing that 'foo' is the thing you want to access?

karlshea’s picture

Status: Postponed (maintainer needs more info) » Active

Ah, yes, sorry for being unclear. It is a node_view override; and you are correct, we would like to access 'foo' in node/1/foo.

merlinofchaos’s picture

You can build a custom context plugin that will do this; this will be the fastest way. Probably CTools should just contain a context plugin to do this so that we can read arbitrary values from the URL, but I've resisted.

Here is proof of concept code, taken from a copy/paste of the string context. This is untested so it will probably NOT work correctly out of the box but may need some adjustment. You'll need to go through the full process of adding a context plugin (implement hook_ctools_pluging_directory() and put this in the right location, probably plugins/contexts)


/**
 * @file
 *
 * Plugin to provide a URL part as a string context
 */

/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'title' => t('URL part 3'),
  'context' => 'ctools_context_create_url_part',
  'keyword' => 'url',
  'context name' => 'string',
);

/**
 * It's important to remember that $conf is optional here, because contexts
 * are not always created from the UI.
 */
function ctools_context_create_url_part($empty, $data = NULL, $conf = FALSE) {
  $context = new ctools_context('string');
  $context->plugin = 'string';

  if ($empty) {
    return $context;
  }

  // The magic is right here:
  $context->data = arg(2);
  $context->title = check_plain($data);
  return $context;
}

To be done right it should also have a form that lets you select which part of the URL rather than hardcoding to arg(2). Would make a valuable patch.

Ashlar’s picture

Status: Active » Closed (fixed)

This support request is now considered to be answered satisfactorily and is being closed. If this is not the case, please clarify your issue and set the status back to active.

bmango’s picture

I know this issue has been closed, but I recently came across exactly this problem. I was using panels to override node_view to display group content. I had wanted to filter the group content based on a taxonomy term in the URL. However I found it quite difficult retrieving the argument from the URL ("group/group-name/term"). I finally managed to do it by using a view pane and using "raw value from URL" instead of "taxonomy term id from URL" in the "provide default argument" section of the context settings. However, using this method meant I needed to use the term ID in the URL instead of the term name, because if there were any spaces or any other odd characters in the term the argument wouldn't be correct.

I was just wondering whether there may now be easier methods to pass a URL argument rather than coding as outlined in #16 (which would test my php/drupal skills rather)?