Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
URL key for themes and data
  • Hello all!

    I'm wondering if a URL system like the one Magento uses (store coffee as the first component of the URI) is possible to do using FuelPHP...

    Main things I need to do is switch themes depending on the code but ignore it when it comes to parsing the URI... but have a default in case an unknown or no code is passed in the URI.

    I don't know if I explained it correctly, so ask me to elaborate if this does not suffice.
  • I don't know Magento, so I haven't got a clue what this is about, sorry. Perhaps some examples?
  • For stores on example.com, I can set store codes that you can use in the URL, for example:

    Electronics Store - Store Code: elstore
    Controller: Controller_Catalog

    So, basically, take into account "elstore" but do not use it in the URL routing...
  • HarroHarro
    Accepted Answer
    You can either use a route to move it to the back of the URI and make it a segment parameter, or define a closure as route, that will get the store code out, and does an HMVC request to the remainder of the URI.
  • Hmm... sounds like it'd fit the bill... any examples on how to use a closure as a route?
  • Looking at this after a few days... I realize this is fine if you know the URL code beforehand, but what if I have to check the code for validity using the database before I can do the routing?
  • If you use database backed routing, the best thing to do is add a generic route that routes all requests to your "lookup" controller, and have that do an HMVC request to the destination found (or throw an HttpNotFoundException if not). It will be more flexible then using a closure (although you should be able to do the same there, it will just become messy with lots of code).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion