I’m trying to setup a webshop that might expand to multilingual down the line.
So instead of having pages for every product and then having to duplicate them to every context/language, I would much rather have a non-MODX database table — let’s call it “products” for now — that stores the basic product information, like a product number, name (that won’t change across the different contexts) and price.
I know the standard .htaccess file take the whole path into a q variable. But I think you would kind of want to process that first in between somewhere.
Or would a separate context with site_url “shop.com/product/” be the better way to go, where there’s just one page there and you get a new q variable value, that has all the information I’d need.
I understand the easy answer is to simply do individual pages. But if there’s a way to save doing duplicate work down the line (and potentially miss out on a few changes), that would be the preferred way to go.
I never knew this one existed. Then again: it’s impossible to know everything that’s out there. And I don’t think I would have ever come to some kind of phrasing of a search query to get it to show up in Google either.
I just gave it a try and it seems to do exactly what I need. I made the global “/product” page and visited “/product/test” and did manage to get the the “test” string.
From there on out, I’ll be able to get the rest of it working as well.
Hi,
I would like to understand in detail how to do it.
I have a /team.html page that reacts based on parameters sent
With
mysite .com/team.html ?idTeam=1
the snippet inside team, go to DB and grab the team with id = 1 and relative data, such as name
If in this table i put a column with “dbalias”, I would like the address URL to be
mysite .com/dbalias.html and not mysite .com/team.html ?idTeam=1
how can I do it with CustomRequest and, above all, with my custom plugin?
Let’s say you make a request to your site with the URL mysite.com/team/member_alias.html. When MODX can’t find a resource with this URL, the event OnPageNotFound is invoked.
You can create a custom plugin that runs on this event.
You then check if the requested URL (usually the request parameter q) has a certain format. (For example something like team\/[a-z_]+\.html.)
If it’s a match, you forward the request to the team.html page using the MODX function $modx->sendForward() and save the alias to the PHP superglobal $_GET or $_REQUEST (E.g. $_GET['team_alias'] = $alias).
On the team.html page you then use a normal snippet to display the correct team member info based on the value of $_GET['team_alias']).
This is also basically how the extra CustomRequest works.
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.