Skip to main content
Share Your Experience: Take the 2024 Developer Survey
11 votes
Accepted

The safest way to edit core Craft files?

You should never edit the core files (i.e. anything below /app), because whatever changes you add might be overwritten any time Craft is updated – or even worse, your amendments might conflict with ...
Mats Mikkel Rummelhoff's user avatar
4 votes

Is there a way to define a global var within a twig block?

This article may help as well: Twig Processing Order & Scope
andrew.welch's user avatar
  • 11.6k
3 votes

Templating basics: extend, include or use?

My setup regarding includes for templates is as follows: I'll have a 'site' structure that looks at /pages/_entry.twig for it's template. But I'd have a range of entry types within this structure, ...
Jay's user avatar
  • 1,042
2 votes

Plugin Development: extending a vendor plugin

In your example, if you do this: $var = new \XXX(); $var->doThis = 'CONTENT HERE'; Then doThis will never exist for class \XXX because \XXX isn't where the method was defined. It would work from ...
Brad Bell's user avatar
  • 67.5k
2 votes

Templating basics: extend, include or use?

I use extend for different entry types. So i have a master.html with the main html construct and includes page parts like header.html and footer.html Then i have a standard.html that extends master....
phaetons's user avatar
  • 705
2 votes
Accepted

Templating basics: extend, include or use?

Hmmm I think I've got it already: _layout.html <!DOCTYPE html> <html lang="de"> {% include "pages/partials/_head.html" %} <body class="body"> {% include "pages/partials/_header....
Urs's user avatar
  • 639
2 votes
Accepted

Not triggering SEOMatic on save element

By setting the regenerateSitemapsAutomatically to false, SEOMatic won't regenerate a sitemap for every entry saved. At the end of the job, I set it back to true and save the first element inside of ...
Joorren's user avatar
  • 305
2 votes
Accepted

Event on new user created

Try $isNew = $user->isNewForSite.
James Smith's user avatar
  • 5,304
1 vote
Accepted

Can a plugin manually raise another plugin's Event?

I've built a plugin which uses it's own events before, I guess the way to do it would be the same for separate plugins, however this is untested for your use case. This should go in your plugin ...
Alec Ritson's user avatar
  • 4,539
1 vote

Set Parent Template Defined Content to Output in Child Template

You could use include...with, as specified in the Twig Docs here Example for your case: {# in Template C #} {% include 'template-d.twig' with {'foo':'Hello World'} %} This should give Template D ...
Sam LeBlanc's user avatar
1 vote

Custom Asset Source Types - not possible

Custom Asset sources are not possible in Craft 2 without some core hacking. However totally doable in Craft 3 (even in the dev preview). There is an example of how to pull it off here.
Brad Bell's user avatar
  • 67.5k

Only top scored, non community-wiki answers of a minimum length are eligible