content management system (CMS) from Pixel and Tonic. Craft is a content management system (CMS) that’s laser-focused on doing one thing really, really well: managing content. And since content comes in all shapes and sizes, we’ve built Craft to be as flexible as possible, without compromising on the ease of use for content authors. [ It will change your life ]
PHP based, content management system 2. Licensed and extendable but not open source 3. Built on Yii (Fun party fact) • Yii is a high-performance PHP framework 4. No “Themes” 5. Templates use Twig 6. One click updates (with database backups) 7. 18 custom field types 8. Content version-ing 9. User roles and permissions 10. Assets 11. Always improving • 186 updates to date
wrong with using Wordpress Craft is your swiss army knife. The right tool for the every project Wordpress is the “as seen on tv” knife kit. Who needs 29 knives when just 1 will do? Or platform of your choice
• PHP 5.3.0 or later with safe mode disabled • MySQL 5.1.0 or later, with the InnoDB storage engine installed • A web server (Apache, Nginx, IIS) • A minimum of 32MB of memory allocated to PHP • A minimum of 20MB of free disk space • A minimum of 1MB of database space Craft requires the following:
STEP 1 Unzip and move to your root folder STEP 2 Rename htaccess to .htaccess in /public STEP 3 Setup a new database using your db program of choice STEP 4 Edit /craft/config/db to match your db settings STEP 5 Visit craft.dev/admin and follow the install process STEP 6
Sections Entries Templates Construct Organize Output Create Out of the box Craft provides 18 different field types. Assets Categories Checkboxes Color Date/Time Dropdown Entries Lightswitch Matrix Multi-select Number Plain Text Position Select Radio Buttons Rich Text Table Tags Users
Sections Entries Templates Construct Organize Output Create Think of sections as empty buckets to organize your content: blog, news, team Singles, channels and structures, oh my! Entries are categorized into 3 different categories: Single pages, channels and structures.
Sections Entries Templates Construct Organize Output Create SINGLE Single pages are usually unique, one off pages like your homepage, about page and contact page CHANNEL Channels are recurring content pages like a blog, news feed, a team page etc. STRUCTURE Structures are content pages that usually need to be given hierarchy and order like sub-nav pages.
Sections Entries Templates Construct Organize Output Create Entries use the fields you’ve built, are organized into sections and store your content. Entries can be previewed and revisions are saved.
Sections Entries Templates Construct Organize Output Create Templates allow you to output your entries for the world to see. The amazing thing about craft is there is no set structure you are required to follow. Content can go anywhere. <h2>Recent News</h2> <ul> {% for entry in craft.entries.section('news').limit(5).find() %} <li><a href="{{ entry.url }}">{{ entry.title }}</a></li> {% endfor %} </ul>
Learn more about user permissions: buildwithcraft.com/docs/users 1. Users can be invited through the admin panel 2. Troubled user? Ban them! 3. Limit admin access through built in permissions • Access can be limited to entries, users and assets 4. Users can be extended through custom fields • Create additional fields like details, location and address 5. Users can be placed into user groups • User groups have predefined access level
more about user assets: buildwithcraft.com/docs/assets 1. Craft allows Assets can be store locally and in multiple locations 2. If your using Craft Pro you can save files to Amazon S3, Rackspace Cloud Files, and Google Cloud Storage 3. Files can be organized through multiple sub-folders 4. You can also create Image transformations so you always have the right size image
more about user assets: buildwithcraft.com/docs/assets 1. Entries can be enabled or disabled at will • Disabled entries will redirect to your 404 page 2. Entries can be schedule to be published or expired at specific dates 3. Entries save revisions so you can roll back to older versions if you need to. 4. Sections can contain multiple entry types each with their own field layouts
sides to the coin with Craft Aside from the index.php file (which helps run Craft) all of your public files go here. Anything that your templates might need to utilize: images, css, javascript etc. should be placed here. Feel free to organize these files how you prefer - it won’t effect the templates. /craft/public
sides to the coin with Craft This is your Craft “core”. No reason to go hunting here. /craft/app Edit your database settings, config settings and routes /craft/config All of your plugins are stored here and are self contained /craft/plugins Error logs, craft cache files and temporary files live here /craft/storage Home sweet home. This is where you will live. /craft/templates
a template engine called twig [ and it rocks ] Read more about twig at twig.sensiolabs.org/ TWIG <?php echo $var ?> {{ var }} <?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } ?> {% for user in users %} {{ user.name }} {% else %} No users have been found. {% endfor %} PHP Output Tags Logic Tags {{ entry.title }} or
allows you output additional html files like footers and sidebars {% EXTENDS %} Extends allow you to create partial html templates so you don’t have to repeat yourself over and over again. {% EMBED %} Embeds work similar to includes but allow you to update content of additional “blocks” so you can build dynamic templates. TEMPLATES AND TWIG Craft uses a template engine called twig {% include “_footer" %} {% extends "_layout" %} {% embed “_custom_embed” %}
block content %} <p>If you see me, you haven’t set your content block yet.</p> {% endblock %} </body> </html> A LOOK AT TEMPLATES A look at /templates/_layout.html
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html craft.entries.section('news').limit(10) “craft” is a global instance used to access anything within craft
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html craft.entries.section('news').limit(10) “entries” are technically a function but I like to think of it as a class You’ll also see craft.assets, craft.pluginName, craft.tags, craft.users
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html craft.entries.section('news').limit(10) “section” is part of the ElementCriteriaModel “news” is the handle that was generated based on your section name
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html craft.entries.section('news').limit(10) “limit” is a parameter that determines which entries to return
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html entry “entry” is what you choose to name the information your selecting This could easily be named content, media, or flubub - your choice.
%} <article> <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1> {{ entry.summary }} <a href="{{ entry.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html entry “entry” is what you choose to name the information your selecting This could easily be named content, media, or flubub - your choice.
%} <article> <h1><a href="{{ content.url }}">{{ content.title }}</a></h1> {{ content.summary }} <a href="{{ content.url }}">Continue reading</a> </article> {% endfor %} WORKING WITH ENTRIES An example of this can be found in /templates/index.html content This is how it would changed if you used something other than entry Each of the following handles are generated off of your field names.
details can be found at buildwithcraft.com/docs/routing URL Search Entries Custom Route HTML files Matching Template Matching Template Matching Template or 404 page or 404 page or 404 page
details can be found at buildwithcraft.com/docs/routing 1) IS IT OWNED BY CRAFT? Craft only intercepts requests that go to your index.php file. Images, CSS and other public files can always be accessed. 2) IS IT A RESOURCE REQUEST? Cpresources including files that power craft (user images, admin css etc.) are intercepted by Craft. 3) IS IT AN ACTION REQUEST? Actions (form submissions, controller actions etc.) always take priority when a URL is accessed. IF NONE OF THESE APPLY CRAFT RENDERS A 404 ERROR 4) IS IT AN ENTRY/CATEGORY REQUEST? Craft checks your entries and categories for matching URLs and determines the best action to do next. 5) DOES THE URI MATCH ANY DYNAMIC ROUTES? Dynamic routes set in your admin panel (or config file) will override your template setup. 6) DOES THE URI MATCH A TEMPLATE? Finally Craft looks at your html files in your template folder to see if it matches to requested URL.
here: buildwithcraft.com/docs/plugins/introduction 1. Plugins must have unique names (folder names and handles) 2. Plugins must have a primary Plugin Class 3. Plugins can run functions on init() or after events happen in Craft 4. Plugins can be used to embed custom variables like {{ craft.pluginName.variable }} 5. Plugins utilize their own templates to build out custom areas in the Craft Admin area
Craft; class SamplePlugin extends BasePlugin { function getName() { return Craft::t(‘Sample Plugin'); } function getVersion() { return '1.0'; } function getDeveloper() { return 'Wrkshop'; } function getDeveloperUrl() { return ‘http://wrkshop.com'; } } This file is required to list and install a plugin
/** * Sample Variable */ class SampleVariable { /** * Output Hello World {{ craft.sample.hello }} */ public function hello() { return 'Hello world!'; } } This allows you to use variables like {{ craft.sample.hello }}
MORE A look at the current craft ecosystem Official Docs Commercial plugins & screencasts Plugins and tutorials Ask Questions CRAFT PLUS BUILD WITH CRAFT http://buildwithcraft.com/community Request an invite SLACK CHANNEL Using include allows you output additional html files like footers and sidebars