insert_view and arguments

tmp - August 1, 2006 - 20:48
Project:Insert View
Version:HEAD
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I made a page (eg ?q=overview) with a [view:players] in it. The players-view (in table format) has an argument "team" (eg Men1, Men2, Women1, Boys1, ...). With this view I can call ?q=players/Men1 to display all players from team "Men1".

But when I call the page ?q=overview/Men1 is give "Page not found".

I'm not sure whether to call it a bug or a feature request.

#1

merlinofchaos - August 1, 2006 - 20:55

What's the 'default' setting on that argument? That is what use Views to determine behavior if an argument is not provided. If you haven't set that or changed it, it defaults ot 'page not found' when you probably want either 'summary view' or 'show all values'.

#2

tmp - August 1, 2006 - 21:22

Hey Merlin,

I have setup an example here : http://drupal.org/node/76622

The argument is set to "Display all values".

If you want I can give you access to my test site

#3

merlinofchaos - August 1, 2006 - 21:35

Ohh! I understand.

Ok, you will need to use PHP to do what you want to do, now that I get it.

<?php
  $players
= views_get_view('players');
 
$games = views_get_view('games');
 
$arg = array();
  if (
arg(1)) {
   
$arg[] = arg(1);
  }
  print
views_build_view('embed', $players, $arg, false, $players->nodes_per_page);
  print
views_build_view('embed', $games, $arg, false, $games->nodes_per_page);
?>

That should work, permitting typos etc.

#4

tmp - August 1, 2006 - 22:07

Thanks for looking into it.

I pasted your code in a page : http://cordoba.sohosted.com/drupal/index.php?q=test_overview
This displays the empty message.

Adding an argument (?q=test_overview/Men1) displays "Page not found" : http://cordoba.sohosted.com/drupal/index.php?q=test_overview/Men1

#5

merlinofchaos - August 1, 2006 - 22:15

Aw crap. That code won't work in a node because of the way aliasing works.

Uh. You probably need to make a module and make it real page.

#6

tmp - August 2, 2006 - 07:11

Hey Merlin,

I have no PHP skills (yet) so I will log this as a feature request for now.

#7

tmp - August 3, 2006 - 09:02

While reading the README file of insert_view I came across this :

TODONE
------
Add support for arguments? [view:viewname=5=arg1,arg2,arg3] is one possible syntax ...

This would be great aswell !!

#8

RayZ - August 3, 2006 - 13:13

And looking at the code, I believe this has been implemented.

#9

Michelle - August 3, 2006 - 13:27

It has; that argument syntax works fine. Glad to see I'm not the only one who got confused by the "TODONE" :)

Michelle

#10

tmp - August 3, 2006 - 13:44

Lol, thanks for pointing that out !! This feature will make my Drupal implementation a lot easier. But my initial feature request still stands ;-)

Indeed you can use [view:viewname=5=arg1] now. But I noticed that the number of nodes to display is mandatory, this [view:viewname=arg1] does not work.

#11

jamesJonas - September 20, 2006 - 15:19

Thanks for a great feature. Use of arguments is a great way to customize page content using views in context.

I'm not quite clear on the syntax.

[view:viewname=5=arg1,arg2,arg3]

Does this mean arg1 = 5 AND arg2 = 5 AND arg3 = 5 ?

Or are agr2 and arg3 passed via the URL...

James

#12

RayZ - September 20, 2006 - 17:22

The 5 is the number of nodes to display and arg1, arg2, arg3 are the values you want to pass to the view as args. For example, you would do something like ...

[view:my_events_view=10=2006,09]

... to display the first 10 events for Sept 2006, if you had an view called 'my_events_view' set up to take the year and month as args.

#13

mlsamuelson - July 12, 2007 - 19:20

@double2: You can leave the number of nodes to display blank, but you do need to have the = in there for it.

Some examples:

[view:viewname=5=arg1] will give you 5 nodes for viewname using arg1

without limiting the number of nodes:
[view:viewname=arg1] incorrect
[view:viewname==arg1] correct - will give you all nodes for viewname using arg1

mlsamuelson

#14

zmove - January 15, 2008 - 07:56

Hi,

And how do I declare an insert view to use multiple arguments ?

I tried :

[view:viewname=4=arg1,arg2,arg3,arg4] => it show only one result
[view:viewname==arg1,arg2,arg3,arg4] => it show only one result too...

#15

mlsamuelson - February 4, 2008 - 18:06

@zmove:

Your Insert View tag syntax is correct. Have you double-checked your views configuration?

mlsamuelson

#16

Summit - November 25, 2008 - 20:47

Bookmarking, so using Insertview in a node can have arguments from the url, great!
how about performance issues, if you need it on several places.

greetings,
Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.