/ucp.php?i=ucp_profile&mode=profile_info
) or by using the module's ID as a parameter (for example /ucp.php?i=200
). Both URLs lead to the exact same page, so one could argue why would you use one over the other... Personally I prefer the 'module ID paramater' version far more because it allows me to target individual modules with marttiphpBB's paramater template variables extension (instead of less specific script names or areas), which means that I can be MUCH more precise with templating.
Yes, I know that his ext also can target the 'verbose' URLs, but not precisely - for example if modules have been moved into different categories, they still inherit the ancestors verbose URL, making them impossible to target with a template variable. This is not the case with the module ID parameter URLs, which always, no matter what, can be targeted individually with a parameter template variable, no matter where they lie in the categorisation of modules.
So...
This has been working fine for me so far, and I've been able to build some very cool navigation UI for the UCP - but I've run into a problem - after a user successfully submits a form in the UCP and is presented with the 'Information' page, they are either
- Redirected automatically to the previous page, but unfortunately this is the 'verbose' URL of the module.
- Or they manually click the 'Return to the user control panel' link and again, unfortunately, this takes them to the 'verbose' URL of the module.
/ucp.php?i=200
page, NOT on the /ucp.php?i=ucp_profile&mode=profile_info
page.Any ideas on how I might attempt this? I've tried using 301 redirects but these are too powerful and of course stop the forms from being submitted in the first place.
Update
I managed to get the breadcrumb links to always link to the module_ID version of the URLs (yay!) by doing the following:
In includes/functions_module.php
Find:
Code: Select all
// if the item has a name use it, else use its id
if (empty($item_ary['name']))
{
$u_title .= $item_ary['id'];
}
else
{
// if the category has a name, then use it.
$u_title .= $this->get_module_identifier($item_ary['name']);
}
Code: Select all
// always use the module_id instead of the module name when building UCP breadcrumb links
$u_title .= $item_ary['id'];
After a bit of digging I've found that the
action
attribute in the page's <form>
tag determines what the eventual redirect link will be - so I can already see an easy workaround to this using javascript to replace that URL with the type I want after the page has loaded.But..... I want to see if I can first try and do this before the DOM loads (with PHP) instead of after (with JS)... so I looked further and found that the
S_UCP_ACTION
variable is what goes in that 'action' attribute - and it is defined in includes/ucp/ucp_xxxx.php
files for each module as $this->u_action)
. However, after trying to dig more, I can't find where this $u_action
variable is made - if I could get to that then maybe I could change it to construct the URL with i=xxx
syntax instead of verbose. If you guys can point me in the right direction I'd appreciate it Update 2 - Solved!
Found the bit I needed, here's how to make the redirects always go to the module_ID variant of the URL:
In includes/functions_module.php:
Find:
Code: Select all
$this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_name)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";
Code: Select all
$this->module->u_action = append_sid($this->module->u_action, 'i=' . $this->get_module_identifier($this->p_id)) . (($icat) ? '&icat=' . $icat : '') . "&mode={$this->p_mode}";