I have created my own extension. This extension can be accessed from different components and parts of the website.
The problem I have is that there could be a number of different URLs that link to this extension. I have a ‘cancel’ button and I can’t work out how I would get this button to link to the previous URL.
Wondering if there is something built into joomla like getPreviousURL? Couldn’t find anything.
EDIT: I should have said that I still want to be able to run my cancel() method. e.g. index.php?option=com_mycomp&task=mycomp.cancel. The cancel() method will then perform a redirection to the previous page.
If I understand your question right, This will help you out for sure. Joomla does not support something like that but Javascript does.
JS
HTML
Updated Answer as required.
PHP
If JavaScript isn’t a possibility, you could use the HTTP_REFERER, sanitize it, and echo it out via PHP.
If you come across any problems let me know.
Update answer – Joomla method