Learning from Happy Lager

58
LEARNING FROM HAPPY LAGER

Transcript of Learning from Happy Lager

LEARNING FROM

HAPPY LAGER

• Super powerful! Super flexible!

• But with all these options, things can get confusing quickly.

• “Channels or structures? Categories or tags? Entry types? Matrix?”

• Documentation and code examples are spread out.

TAGSFeatures:

https://buildwithcraft.com/features/categories-and-tags

TAGSTags in Docs:

http://buildwithcraft.com/docs/tags

TAGSTags Field:

http://buildwithcraft.com/docs/tags-fields

TAGScraft.tags:

http://buildwithcraft.com/docs/templating/craft.tags

TAGSTagModel:

http://buildwithcraft.com/docs/templating/tagmodel

TAGSElementCriteriaModel:

http://buildwithcraft.com/docs/templating/elementcriteriamodel

TAGSGet Help:

http://buildwithcraft.com/help/active-tags

SPEAKING OF TAGS…

THINGS HAPPY LAGER DOESN’T COVER

• Categories

• Tags

• Locales/multilingual

• Users, user groups, registration, etc.

• {% cache %} • {% nav %}

WHAT’S IT GOOD FOR?• Client Demos

Entry drafts and versioning! Live previews!

• Content modeling examplessections, fields, entry types, assets, matrix fields, etc.

• Concrete template code examples{% set thingy = craft.entries.relatedTo(theNameofThatThingGoesHere) %}Where does that come from?

• Cool tricks & nifty ideas

ON DEMANDdemo.buildwithcraft.com

GITHUBhttps://github.com/pixelandtonic/HappyLager

GITHUB

GITHUB

GITHUB

GITHUB

CONTENT MODELING

Home

About Services Work News Search

Home

About Services Work News Search

ServicesEntries

WorkEntries

NewsEntries

Home

About Services Work News Search

ServicesEntries

WorkEntries

NewsEntries

single

single single

structure channel channel

single X X

INDEX SINGLES

• Services Index for a Structure

• Work Index for a Channel

• News... no need for a single.

Home

About Services Work News Search

ServicesEntries

WorkEntries

NewsEntries

single

single single

structure channel channel

single X X

SERVICES INDEX

Work Index content

Work entries (structure sorting)

SERVICES INDEX

WORK INDEX

Channel entries sorted by date

NEWS

Channel entries sorted by date

paginated!

INDEX SINGLES

• Control content for that page or section

• e.g. section title, header image, breadcrumb, etc.

• Control the route in the control panel

• /work could be change to /our-work later without worrying about updating any template file names or code.

ROUTES

Examples of 3 routing methods:

• Entry request: work, work/{slug}, about

• Template file paths: news... and about?

• Dynamic routes: search/results => search/_results

Home

About Services Work News Search

ServicesEntries

WorkEntries

NewsEntries

Locations(structure)

single

single single

structure channel channel

single X X

related

LOCATIONSbottom of the About page

RELATED SERVICESWork entry

Selected entries from the Services section

RELATED SERVICESWork entry

entry.servicesPerformed

Sections

Field Name About Homepage Locations News: Article News: Link Services Services Index Work Work IndexFooter Content

(Globals)Site Assets

(Assets)

Address U

Article Body X X X X

Background Color U

Body X X X

Client Logos U

Contact Methods U

Contact Us Label U

Copyright Notice U

Email X X

Featured Image X X X X X

Featured Thumb U

Heading X X X X X

Hero Image U

Index Heading not used anywhere

Link URL U

Service Body U

Service Icon U

Services Performed U

Short Description X X X X X

Subheading X X

Testimonials U

Theme U

= Used in multiple sections = Unique field used in only one section

FIELDS

short description

“GALLERY” MATRIX BLOCK

short description

related assets

field instructions will be the same everywhere the

field is used.

?

CODE EXAMPLES +

TWIG TRICKS

EXTENDING LAYOUTS

{% extends "_layouts/site" %} {% block main %} ... {% endblock %}

Did you know you can extend more than once?

EXTENDING LAYOUTS

_layouts/base.html

about/index.html

_layouts/site.html

EXTENDING LAYOUTS

base.html

site.html

index.html

EXTENDING LAYOUTS

base.html

site.html

index.html

base.html

???.html

EXTENDING LAYOUTS

_layouts/base.html

about/index.html

_layouts/site.html

childparent

childparent

BLOCKS & PARENT()_layouts/site.html

child template can pull the parent’s content

MAIN NAV ARRAY

ASSET TITLES FOR IMAGE ALT ATTRIBUTES

ENVIRONMENT VARIABLEScraft/config/general.php

_layouts/site.html

ENVIRONMENT VARIABLES

ENTRY VARIABLE

GOOGLE MAPS URL

STRING REPLACE FOR COPYRIGHT YEAR

ARTICLE BODY MATRIX

articleBody

Sections

Field Name About Homepage Locations News: Article News: Link Services Services Index Work Work IndexFooter Content

(Globals)Site Assets

(Assets)

Address U

Article Body X X X X

Background Color U

Body X X X

Client Logos U

Contact Methods U

Contact Us Label U

Copyright Notice U

Email X X

Featured Image X X X X X

Featured Thumb U

Heading X X X X X

Hero Image U

Index Heading not used anywhere

Link URL U

Service Body U

Service Icon U

Services Performed U

Short Description X X X X X

Subheading X X

Testimonials U

Theme U

= Used in multiple sections = Unique field used in only one section

FIELDS

1

2

3 4

56

7 8

910

DEMO OF COMPLEX MATRIX CODE…

THE END