Waqar Azeem
Waqar Azeem

Reputation: 13

Php MVC dynamic urls

I want to know if its possible to create urls dynamically in MVC. Example i am building a shopping store in which i have categories and products. Now if i use product before calling category name or product name it works (http://www.example.com/products/mycategory). But i don't want to use products in the center the URL that i require is http://www.example.com/mycategory.

Same this i want for the content pages.

Can any body help me out on this matter.

Upvotes: 0

Views: 645

Answers (1)

Darren
Darren

Reputation: 13128

I'll throw it up in an answer here for you. Basically if you're following MVC structure and all, your controllers are always your endpoints that are visible to the user.

Sine that is the case, all you want to do is create a new controller that matches the term you want to use.

class mycategoryController extends Controller {

    function index() {
        // do your stuff...
    }

}

I can't say exactly how you create your controllers, but that will give you the general gist of things.

Upvotes: 1

Related Questions