Re: [Dave] Question about Filename field translation
Hi Dave,
I'm looking up the record with both the num and title (trying to at least) fields. So there can still be duplicate titles in the table. I should have mentioned that.
Looking up both fields prevents duplicate pages, otherwise you can write anything between the ? and the num and the page resolves to the same content based on the num. I'm also enforcing lowercase. Throwing a 404 error page if the record isn't found.
Hello-World-1 (200)
Goodbye-World-1 (200)
heLlo-wOrlD-1 (200)
Should be:
Hello-World-1 (200)
Goodbye-World-1 (404)
heLlo-wOrlD-1 (404)
IDEALLY, I'd like to add another field to the table that gets auto-populated with the slug - where in my case the slug is the Filename field + num. I'm not too concerned with being able to edit the slug, although that would be nice - kind of like what Wordpress does with their titles.
That way I can easily lookup just the 'slug' field instead of both the 'title' and 'num' fields with no need to worry about de-normalizing the 'title' field for special characters.
Let's say 'title' is my Filename field...
num: 100
title: Get 20% Off Product ABC
slug: get-20-off-product-abc-100
Request comes in, query the db using the slug and return the content or throw a 404 if record isn't found.
Basically, instead of a _link field, I want a _slug field as I described.
I'm also using mod_rewrite to rewrite the viewer urls, but that doesn't impact anything here. Also note I already made slight adjustments to the _link in viewer_functions.php such as strtolower().
/products/product.php?the-slug gets rewritten to /products/the-slug
OTHERWISE, I need a way to de-normalize the 'title' field based on the Filename field.
Hope that makes sense, took a while to write it.
Thanks!