Comments (11)
Thanks for the heads-up on this @fturcheti. The issue is definitely an unintended side effect of what we saw as a way to clean things up and improve the cleanliness of the organization.
What I'm thinking is that we version the prior structure as the 1.x version of the starter theme and this new org marks the beginning of the 2.x branch. This also will allow us to lean into the new features of 2.x w/o worrying that we're messing up the workflow of existing patterns and development expectations.
from starter-theme.
I'm using Timber for the first time in the website I'm working on, so if I misunderstood something I'd love to get some feedback on this.
Also, as I like this idea of having the theme files in the /theme
folder, I'm bypassing the issue I pointed by setting a context variable in my functions.php
and using its value instead of calling theme.link
:
$context['theme_uri'] = dirname( get_template_directory_uri() );
from starter-theme.
@szepeviktor I guess your approach is way more sane and it makes sense.
I just wanted to try and see if I could make it work and also because in my mind {{ theme.link }}
, {{ site.theme.link }}
, {{ theme.path }}
and {{ site.theme.path }}
should logically return the link or the path of the theme's root folder and not wherever index.php
and style.css
are.
I guess the thing about putting those in a /theme/
subdirectory is fundamentally flawed and not the WordPress way but I like it this way…
from starter-theme.
Good point.
I suggest you not to use an intermediate variable but explicit ones for e.g the static/
directory.
Only development files live in the theme root.
from starter-theme.
Thank you, Viktor.
I've set a global context variable static_dir
pointing to static/
for the cases in which I need to link files that live in that folder.
And how would you fix the link below? It's currently broken in the starter-theme, right?
starter-theme/views/html-header.twig
Line 12 in 37fe919
I had to keep a context variable theme_dir
for this specific case.
from starter-theme.
There are a plethora of ways we may go!
- Move
humans.txt
file to/theme
- Patch stuff in
html-header.twig
- Make Timber provide a root path variable ✅
- Make the starter-theme do the same
from starter-theme.
@szepeviktor is there an upside to the new structure? i spent my afternoon setting this up to play along with my gulp config and i cannot get it to work the way i want. i can't go up from the theme folder and it looks like i will have to compile into the theme/dist folder to get it to work.
from starter-theme.
AFAIK If you are compiling things like SASS into CSS - you should put all of that in the root, above theme/
.
from starter-theme.
This is now set. Fans of the new organization can find it here: https://github.com/timber/starter-theme/tree/2.x
... this will become the default once 2.x is released. But in the meantime (esp. for WordPress.org deployments) the old familiar file stricture scheme reigns supreme!
from starter-theme.
@fturcheti My approach to this is probably very bad but it works… what I do is override link()
by subclassing Timber\Theme
inside of the Timber\Site
subclass in my custom theme. I'm not really fluent with PHP and not really knowledgeable about Timber.
class Website extends Timber\Site
{
public function __construct()
{
add_action('after_setup_theme', array($this, 'theme_supports'));
add_filter('timber/context', array($this, 'add_to_context'));
add_filter('timber/twig', array($this, 'add_to_twig'));
add_action('init', array($this, 'register_post_types'));
add_action('init', array($this, 'register_taxonomies'));
parent::__construct();
$theme = new class() extends Timber\Theme
{
public function link()
{
return dirname(get_stylesheet_directory_uri());
}
};
$this->theme = $theme;
}
…
then I override the global context:
…
public function add_to_context($context)
{
$context['theme'] = $this->theme;
return $context;
}
…
from starter-theme.
Why don't you introduce a new theme.something
that points to the directory/URL of interest?
theme.assets
👉🏻 my-timber-theme/assets
from starter-theme.
Related Issues (20)
- Uncaught SyntaxError: Cannot use import statement outside a module HOT 1
- Fatal error when importing namespaced class HOT 11
- Advice to install timber. HOT 3
- Customise starter theme for my use HOT 2
- Installing Timber on Local Environment with Composer 2.0 Issues HOT 3
- Add wp_body_open function to base.twig
- Starter Theme - php support
- Can starter-theme v2 for timber v2 be already tested (via composer)? HOT 3
- Question: What is sidebar_class? HOT 1
- Create a namespaced version of Timber with Mozart HOT 3
- Timber Error loading template files - existing .twig files not found in spec'd dir path HOT 2
- Issue with 2.0 theme after most recent folder restructuring HOT 5
- Image path/convert issues in Multisite install HOT 1
- FATAL error on timber/starter_theme 2.x autoload.php reference using wp-cli HOT 4
- Error: Call to protected Timber\Post::__construct() from global scope HOT 8
- TODO's after Timber 2.0 HOT 4
- Can't install timber-starter-theme 2.0; 1.2 is installed instead HOT 4
- Simplify header/footer usage
- Use wp_enqueue_style and wp_enqueue_script instead of hard including the file
- Publish starter theme again to the Timber packagist HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starter-theme.