Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.
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

Open

Description

@Ultimater

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){}

Activity

  1. Jurigag commented on May 8, 2017

    @Jurigag
    Contributor

    Good idea, i like this. Could maybe avoid somehow usage of js and handle it in php.

  2. Ultimater commented on May 8, 2017

    @Ultimater
    SponsorMemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions