Hi,
I'm trying to create a module that creates a web-based SFTP file browser. I've defined a menu item like this:
$items["sftp/%"] = array( "title" => "File Access", "access arguments" => array("access content"), "page callback" => "drupal_get_form", "page arguments" => array("sftp_index", 1), "type" => MENU_CALLBACK, );
The sftp_index function is getting called correctly for paths like:
/sftp/foo /sftp/bar
But when I go to:
/sftp/foo/bar
my function is only getting the "foo" part of the URL, and not "bar". How can I capture the entire additional URL into an argument to the function? Doing something like creating an "sftp/%/%" items and then an "sftp/%/%/%" item (and so on) obviously won't work, as the path names can get arbitrarily large and complex.
Is there any way to cause the menu system to capture the entire URL path after the "sftp/" part and pass it to the function?
Tim Gustafson Baskin School of Engineering UC Santa Cruz tjg@soe.ucsc.edu 831-459-5354
You can access any additional arguments using the arg() function: http://drupalcontrib.org/api/function/arg/6 Then you only need the menu callback for sftp/% to be sure ther is at least one argument.
Am 02.06.2010 um 18:20 schrieb Tim Gustafson:
Hi,
I'm trying to create a module that creates a web-based SFTP file browser. I've defined a menu item like this:
$items["sftp/%"] = array( "title" => "File Access", "access arguments" => array("access content"), "page callback" => "drupal_get_form", "page arguments" => array("sftp_index", 1), "type" => MENU_CALLBACK, );
The sftp_index function is getting called correctly for paths like:
/sftp/foo /sftp/bar
But when I go to:
/sftp/foo/bar
my function is only getting the "foo" part of the URL, and not "bar". How can I capture the entire additional URL into an argument to the function? Doing something like creating an "sftp/%/%" items and then an "sftp/%/%/%" item (and so on) obviously won't work, as the path names can get arbitrarily large and complex.
Is there any way to cause the menu system to capture the entire URL path after the "sftp/" part and pass it to the function?
Tim Gustafson Baskin School of Engineering UC Santa Cruz tjg@soe.ucsc.edu 831-459-5354
-- [ Drupal support list | http://lists.drupal.org/ ]
If arg() is your answer, you're asking the wrong question. :-)
As an experiment, Tim, can you try using a page callback that doesn't go through drupal_get_form? It does some weird stuff, so you should eliminate that as a potential source of trouble.
I think what you're trying to do should work, which is why I recommend eliminating some variables.
--Larry Garfield
On Wednesday 02 June 2010 11:33:58 am Hadubard wrote:
You can access any additional arguments using the arg() function: http://drupalcontrib.org/api/function/arg/6 Then you only need the menu callback for sftp/% to be sure ther is at least one argument.
Am 02.06.2010 um 18:20 schrieb Tim Gustafson:
Hi,
I'm trying to create a module that creates a web-based SFTP file browser. I've defined a menu item like this:
$items["sftp/%"] = array( "title" => "File Access", "access arguments" => array("access content"), "page callback" => "drupal_get_form", "page arguments" => array("sftp_index", 1), "type" => MENU_CALLBACK, );
The sftp_index function is getting called correctly for paths like:
/sftp/foo /sftp/bar
But when I go to:
/sftp/foo/bar
my function is only getting the "foo" part of the URL, and not "bar". How can I capture the entire additional URL into an argument to the function? Doing something like creating an "sftp/%/%" items and then an "sftp/%/%/%" item (and so on) obviously won't work, as the path names can get arbitrarily large and complex.
Is there any way to cause the menu system to capture the entire URL path after the "sftp/" part and pass it to the function?
Tim Gustafson Baskin School of Engineering UC Santa Cruz tjg@soe.ucsc.edu 831-459-5354
Larry Garfield wrote:
If arg() is your answer, you're asking the wrong question. :-)
As an experiment, Tim, can you try using a page callback that doesn't go through drupal_get_form? It does some weird stuff, so you should eliminate that as a potential source of trouble.
I think what you're trying to do should work, which is why I recommend eliminating some variables.
I actually thought arg was the correct answer here as well. Not using drupal_get_form may well be what is needed but arg() would still need to be used to get the pieces.
$args = arg(); array_shift($args); $ftp_path = implode('/', $args);