You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 4, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 4, 2026. It is now read-only.
New Thread from Category doesn't preselect Category from dropdown #375
This isn't a feature request per se, as it's the expected functionality.
Go to https://forum.phalconphp.com/category/21/beginners for example (as it has the most threads).
Then click "Start a Discussion" on that page, there's a "Category" dropdown to choose the category again. Expected behavior is it should pre-select "Beginners" in this case. I'd like to suggest use the referrer to determine what to highlight. This JavaScript has been tested thoroughly and would get the job done:
try{
(function(){
var r = document.referrer, m = r.match(/\/category\/(\d+)\/([^\/]+)/), e = document.getElementById("categoryId"), o = e.options;
for(var i=0;i<o.length;i++)if(o[i].value==m[1] && o[i].text.match(/(\w+)/)[1].toLowerCase() == m[2].match(/(\w+)/)[1].toLowerCase())e.selectedIndex=i;
})();
}catch(E){}
If we're aiming at a PHP solution, we could read $_SERVER['HTTP_REFERER'] and parse it using a similar regular expression, then add a selected to the option to select. We could also change the navigation a bit and ditch the refe(r)rer altogether by creating a different create new topic link which we can extract the category from.
Activity
Jurigag commentedon May 8, 2017
Good idea, i like this. Could maybe avoid somehow usage of js and handle it in php.
Ultimater commentedon May 8, 2017
If we're aiming at a PHP solution, we could read
$_SERVER['HTTP_REFERER']and parse it using a similar regular expression, then add aselectedto the option to select. We could also change the navigation a bit and ditch the refe(r)rer altogether by creating a different create new topic link which we can extract the category from.