Mixing Wordpress with A Flat File CMS

Nat

Joined
Nov 18, 2014
Messages
555
Likes
345
Degree
2
I've got a (flat file) Twig template in Phile that I love for essentially "product listing." I really want to use this in a WP website for organizing products and logically separating very distinct parts of the site. The upside would be that I've already got the twig structure I like, I would be able to completely separate it from the WP database, it will be faster, and because I don't need any of the WP functionality for this. However, I don't know the "coding etiquette" of this. I'm guessing the world will end if I drop Pico/Grav/Phil straight into domain.com? I'll have to use a folder domain.com/products/ that is not currently in use with WP, but as long as WP isn't using that slug there shouldn't be any conflicts, right?

I guess my confusion about potential conflicts comes from my lack of understanding at how site requests are handled.
 
Whoever controls the index.php file within the root is in control of the main domain/site. I have a setup with Pico controlling the root domain and put wordpress inside a /folder/ so wordpress only associates with that folder. I prefer it that way. I also have a setup where wordpress controls the root, the /index.php, and Pico controls a single folder. It's really your call.

If you are using apache, make sure there are respective .htaccess files within root and the /folder/ areas.

if you are using NGINX, you'll need to edit your example.com.conf file to get things going the same way (NGINX Guide).
 
I've been testing it out by hand since although I might not know "best practices" I can trial and error myself into figuring out what wont work. Wordpress and Phile do not play nice when they're both at the root (even though Phile's folder structure has content is stored in /content/) and I'm assuming it is because of the .htaccess rewrites and the index file. Simply dropping Phile into a directory lets it override anything WP for anything /dir/ and /dir/anything. So as long as this isn't advised against, I think I'm safe.

My only issue is that I don't want a single /dir/ with everything Phile after it. I'd like to have domain.com/product-cat/ and domain.com/product-cat2 as Phile, but this way it will be forced to look like domain.com/products/product-cat/ and domain.com/products/product-cat2/.... unless I install Phile in each of those directories... but that would be stupid and a pain with updates.
-----------
Edit: Damn it, @CCarter ninja'd in. Okay, seriously, thanks for the validation of this not being a stupid thing to do. I know people add blogs all the time to existing sites in their own folders, but I wasn't positive about the reverse on a CMS like WP that rewrites a lot.

Edit 2: @CCarter Okay, so dumb SEO question. If I'm going to list products with Phile that span a wide range, like tech - supplies - environmentally friendly home products, is it best to create a dir /shop/ or /store/ or /s/ and then use additional folders as categories? So /shop/tech/product-name-here, or is it worth making several category folders and several Phile "installations" so that I don't use a generic folder like /shop/?

Its also pretty easy to display category lists in /shop/category/ and have each item slug actually just be /shop/item-of-any-category, but still an issue of /shop/ or not.
 
Last edited:
I don't understand why not install Phile simply on domain.com/products/ and create categories like /products/cat1/ and /products/cat2/ ? As long as it stays within the /sub-folder Phile will control everything inside there.

Edit: the only other solution is Phile controlling everything, and regulating wordpress to a folder, in the end there can only be 1... as in one controlling the index.php file within root.
 
  • Like
Reactions: Nat
I don't understand why not install Phile simply on domain.com/products/ and create categories like /products/cat1/ and /products/cat2/ ? As long as it stays within the /sub-folder Phile will control everything inside there.

Edit: the only other solution is Phile controlling everything, and regulating wordpress to a folder, in the end there can only be 1... as in one controlling the index.php file within root.

My bad, I was still making edits to the earlier post. There isn't any issue with making categories after /store/ besides creating longer URLs. I don't have enough experience with SEO know if its worth the extra effort to shorten a URL & remove a generic product keyword from the URL.
 
Sounds like the best route to go would to set up some rewrites in your apache config file or .htaccess.

I haven't done this in a while but it would look something like, this (this may not be 100% correct I have not tried it):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /product/
RewriteRule ^productdir\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /productdir/index.php [L]
</IfModule>

Productdir being the directory of your other stuff.
 
Sounds like the best route to go would to set up some rewrites in your apache config file or .htaccess.

I haven't done this in a while but it would look something like, this (this may not be 100% correct I have not tried it):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /product/
RewriteRule ^productdir\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /productdir/index.php [L]
</IfModule>

Productdir being the directory of your other stuff.

I've been fooling with Phile's .htaccess. Can't get anything to work. I don't know much about htaccess, so I've just been throwing shit in and refreshing to see if anything changes... and nothing ever happens, haven't even gotten any real errors. Spent too long on this, just gonna start adding content now.
 
Back