-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates folder #1429
Comments
For reference, I learnt about it here: https://github.com/dxw/govsite/ |
The only issue I see, is that when you move functions.php it won't be able to locate_template the /lib files since WP updates TEMPLATEPATH value to theme/templates folder. |
For the record, i love the restructuring ideas implemented in govsite. Kudos @dxw. |
@QWp6t I would happily implement and submit a pull request myself but I think we need to discuss what to do with functions.php. We have three options I can see
|
would love to do something like this. it's time to start [publicly] talking about next steps regarding PHP in the theme. if we are going to be adding functionality like this, it would ideally be managed outside of the theme itself. the best solution is probably to add composer to sage. that unfortunately would bring our package manager count to 3 - npm, bower, and composer. by adding composer to sage we could also separate the following components into their own repos/projects:
related reading: http://tomjn.com/2014/04/01/theme-composition-vs-frameworks/ we've discussed this quite a bit internally but haven't made any decisions yet. |
playing with this right now... wordpress requires functions.php, style.css, and screenshot.png to belong in the subdirectory with the primary wordpress templates (index.php, etc). it would be odd to have those files in a dir called |
Yeah I know. That is why I didn't actually do anything or submit a pull request. |
seems like we could modify the theme wrapper and also use a utility like #1414 to replace like i mentioned in my previous comment, this is going to require us adopting composer in the theme and separating out components. |
You know, over time I've found myself favoring what I call "View Functions" over partials. These are functions that I define with the intention of using throughout my templates, something like You could, of course, rely on the fact that the included file will inherit the current scope of variables, but I find this to be confusing at best -- when viewing the partial I exclaim, "Where the heck did that variable come from?!" I realize this doesn't exactly mean that the idea of the suggested feature is a bad one, but I felt I'd throw out there that this isn't something I personally miss as a feature, as I think there's a generally better alternative. |
@JasonTheAdams, The get_component function mentioned above, #1414, is essentially a "view function" without being tied to a specific item. The first parameter to the function is a component name and the second is an array of arguments to pass to the component files scope. @retlehs Theme composition sounds really interesting! |
Any updates on this? I'm starting to play around with the idea of using a "Get" namespace, which includes functions to load a "part" or "component" with the folder paths built in. I am unsure as far as the regular templates "404.php", "page-home.php", etc. I'm guessing that would require hooking into some WordPress filters to override the deafult. |
Just found this on core trac: https://core.trac.wordpress.org/ticket/31475 Don't know how much interest is in that ticket, but it would simplify how we have set up templates in Sage. |
Yeah, I don't count too much on anything getting through WordPress core process. I have seen too many good ideas abandoned, even some added and then removed. |
I have fiddled around with different product structure pretty extensively - and I do think it is a must! @schrapel 's example was a good start. - For someone like me who really uses this as a leaping pad, I'd love to see more lib folders or quicker, easier ways to integrate them into the theme. I, too, have a lot of template "parts" but don't always want to shove them all in the same folder. Some are page specific, others post specific, and others app integration specific and folder organization is huge for me! :-) I should start fiddiling with that again and maybe share some quick solutions, see what I can do! |
would love to know more about how some of y'all might be handling this right now |
going to close this out as @QWp6t has solved this issue in the upcoming sage 9 (more info soon). check out the folder structure in both the theme root and the templates directory: https://github.com/roots/sage/tree/sage-9 |
From what I see on Sage 9.0.1 and latest WP 4.9.7: It make my woocommerce look for a woocommerce.php into /resources/ instead of /resources/views using TEMPLATEPATH variables. Shouldn't TEMPLATEPATH be Thanks ! Note: for improving https://github.com/mtx-z/Sage9-Woocommerce-Integration |
Lines 63 to 84 in fd2a94f
|
Thanks.
Right after it, or from the app controller always gives me (from a WP or Woocommerce endpoint), even after removing all updates made :
I'm gonna check on a clean install and see. Thanks again. |
@knowler actually those docs aren't correct anymore. we used to have a hack that would cause the STYLESHEETPATH to be changed to the path of the views, but it was a little too ham-fisted and caused errors for some users, including "broken theme" errors in certain situations. so ... i guess i should update the docs lol @mtx-z the current setup is deliberate. it ensures parity between stylesheetpath and templatepath, making sage more compatible with child themes. we use template hierarchy filters to direct wordpress to the views. you can filter woocommerce's locate_template function or just stick with resources/woocommerce and add that folder your view paths in config/view.php. or you're welcome to re-add the previous option hack if you want. |
i'm going to go ahead and lock this, though, since this issue is 3 years old. |
This folder structure is way better than having a bunch of files in the root with markdown, bower, etc. What do you think?
The text was updated successfully, but these errors were encountered: