1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

building a url using database data

Discussion in 'XenForo Development Discussions' started by Lee, Jun 16, 2013.

  1. Lee

    Lee Well-Known Member

    What I am looking to do is expand upon this thread;
    where I created a model and controller to allow me to grab the last 5 articles and navigation menu.

    I added a route called home to the database, but now what I want to do is expand upon that route so clicking each category in the menu takes you to a list of articles dedicated to that category with the route of home/catergoryname.id and similarly, clicking a article title takes you to a route of home/category.id/articlename.id

    How would I go about writing the code to select the data based upon the url?

  2. Lee

    Lee Well-Known Member

    I would be happy with how xF handles it with its resource manager, i.e. categories and articles within them.

    We could have a structure like;


    if that makes it any easier to accomplish what I want?

    I just need help setting up the model and controller to do what I want and construct the URL - I can have a go at doing everything else myself.
  3. Lee

    Lee Well-Known Member

    Anybody got any help at all? :)

  4. Jeremy

    Jeremy Well-Known Member

    Bumping your thread within a day is slightly unnecessary. However, you define a route, which you have as "home". When you access that route, any data is sent to actionIndex. If you define more actions, such as actionArticles and actionCategories, you'll be receiving data in those controller actions.
  5. Lee

    Lee Well-Known Member

    Just eager to learn ;)

    Thanks for the reply. I understand that part, what I don't understand is how to take the data from the url to select the right information from the database. Or the correct way to build the url and show the relevant data per url...
  6. Jeremy

    Jeremy Well-Known Member

    Look at XenForo_Link and XenForo_Input

Share This Page