Successfully reported this slideshow.
Your SlideShare is downloading. ×

CraftCMS 3.x Deep Dive

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 59 Ad
Advertisement

More Related Content

Similar to CraftCMS 3.x Deep Dive (20)

More from Digital Surgeons (20)

Advertisement

Recently uploaded (20)

CraftCMS 3.x Deep Dive

  1. 1. deep dive
  2. 2. deep dive[0] Introduction $presentation = array( 'Introduction', 'Yii', 'Request Handling', 'Data Structure', 'Module & Plugin Overview', 'Q&A' );
  3. 3. deep dive[1] Yii
  4. 4. deep dive[1] Yii Yii is an object-oriented
 model-view-controller
 framework for PHP.
  5. 5. deep dive[1] Yii
  6. 6. deep dive[1] Yii }
  7. 7. deep dive[1] Yii Yii provides a way for namespaces applications to interact with each other.
  8. 8. deep dive[1] Yii Yii provides routing.
  9. 9. deep dive[1] Yii Yii provides twig.
  10. 10. deep dive[1] Yii Yii provides error handling.
  11. 11. deep dive[1] Yii Yii provides events.
  12. 12. deep dive[1] Yii provides it's own routing. 🖕🖕
  13. 13. deep dive[1] Yii provides its own twig. 🖕🖕
  14. 14. deep dive[1] Yii doesn't provide it's own error handling. 👍 👍
  15. 15. deep dive[1] Yii doesn't provide it's own events. 👍 👍
  16. 16. deep dive[1] Elements use craftservicesElements;
  17. 17. deep dive[1] Elements In Craft almost everything is an element.
  18. 18. deep dive[2] Request Handling Let's look at an incoming Craft request.
  19. 19. deep dive 0.
 The request will only go to craft if the server routes it to the index.php file. [2] Request Handling
  20. 20. deep dive 1. Is it an action?
 If the URL begins with actions/ it gets routed to a controller. [2] Request Handling
  21. 21. deep dive 1. Is it an action?
 The controller is either built-in, or provided by a module or plugin. [2] Request Handling
  22. 22. deep dive namespace craftcontrollers; use Craft; class UsersController extends Controller { public function actionLogin() { if (!Craft::$app->getUser()->getIsGuest()) { // Too easy. return $this->_handleSuccessfulLogin(false); } } } 1. Is it an action?
 The controller is either built-in, or provided by a module or plugin. GET /actions/users/active POST /
 <input type="hidden" name="action" value="users/save-user"> [2] Request Handling
  23. 23. deep dive 2. Is it an element?
 Does it match an element's URI? [2] Request Handling
  24. 24. deep dive element:
 a thing that can hold data craftelementsAsset craftelementsCategory craftelementsEntry craftelementsGlobalSet craftelementsMatrixBlock craftelementsTag craftelementsUser verbbsupertableelementsSuperTableBlockElement [2] Request Handling
  25. 25. deep dive craft_elements id 28 fieldLayoutId 31 type craftelementsEntry enabled 1 craft_elements_sites id 32 elementId 28 siteId 1 slug about-us uri company/about-us [2] Request Handling
  26. 26. deep dive craft_elements id 28 fieldLayoutId 31 type craftelementsEntry enabled 1 [2] Request Handling
  27. 27. deep dive craft_elements id 28 fieldLayoutId 31 type craftelementsEntry enabled 1 craft_elements_sites id 32 elementId 28 siteId 1 slug about-us uri company/about-us routing uri [2] Request Handling
  28. 28. deep dive 3. Does the URI match a route or URI rule? return [ // Route blog/archive/YYYY to a controller action 'blog/archive/<year:d{4}>' => 'controller/action/path', // Route blog/archive/YYYY to a template 'blog/archive/<year:d{4}>' => ['template' => 'blog/_archive'], ]; config/routes.php <h1>Blog Entries from {{ year }}</h1> [2] Request Handling
  29. 29. deep dive 4. Does the URI match a template? @webroot/templates/single.twig [2] Request Handling
  30. 30. deep dive 4. Does the URI match a template? @webroot/templates/single.twig Yii alias [2] Request Handling
  31. 31. deep dive 5.Well I guess we'll just 404. [2] Request Handling
  32. 32. deep dive[3] Data Structure Let's visualize the CraftCMS DB Structure
  33. 33. deep dive Ok maybe let's not do that. [3] Data Structure
  34. 34. deep dive Let's look at the Wordpress schema. [3] Data Structure
  35. 35. deep dive[4] Module & Plugin Overview Not suited for the complex content architecture we require.
  36. 36. deep dive[4] Module & Plugin Overview Let's talk about plugins.
  37. 37. deep dive Plugins and modules are basically justYii modules (sort of like Craft is!) [4] Module & Plugin Overview
  38. 38. deep dive Plugins: Installed through Composer,
 can be turned on and off in admin.
 (Usually) site-agnostic functionality Modules: Hardcoded into composer andYii configs. Cannot be turned off in admin.
 (Usually) site-specific functionality [4] Module & Plugin Overview
  39. 39. deep dive[4] Module & Plugin Overview
  40. 40. deep dive This is meta because Craft implements all of these things on its own. [4] Module & Plugin Overview
  41. 41. deep dive CSS, JS, and Images needed in the Admin side of Craft [4] Module & Plugin Overview
  42. 42. deep dive Tasks that can be run through the Craft CLI [4] Module & Plugin Overview
  43. 43. deep dive Endpoints that are accessible through a URL path [4] Module & Plugin Overview
  44. 44. deep dive Main application class file. Registers hooks, events, etc [4] Module & Plugin Overview
  45. 45. deep dive New elements (like SuperTable Blocks for example) [4] Module & Plugin Overview
  46. 46. deep dive New fields (like a markdown editor that stores HTML) [4] Module & Plugin Overview
  47. 47. deep dive New queued tasks (like image transformation) [4] Module & Plugin Overview
  48. 48. deep dive Installation / uninstallation migrations [4] Module & Plugin Overview
  49. 49. deep dive A "template" for a custom data structure [4] Module & Plugin Overview
  50. 50. deep dive A way to represent data from a model and define how it is stored / retrieved in the DB [4] Module & Plugin Overview
  51. 51. deep dive The "business logic" of the application/plugin/module [4] Module & Plugin Overview
  52. 52. deep dive Twig templates for the admin side of your plugin [4] Module & Plugin Overview
  53. 53. deep dive Functional additions toTwig (like twig-dig!) [4] Module & Plugin Overview
  54. 54. deep dive Add twig pages that appear under "Utilities" in the Admin [4] Module & Plugin Overview
  55. 55. deep dive Add custom twig variables accessible under the craft namespace. (Like {{ craft.testvariable }}) [4] Module & Plugin Overview
  56. 56. deep dive Widgets for the admin dashboard. [4] Module & Plugin Overview
  57. 57. deep dive[5] Q & A Q&A

×