share content across subsites in plone: cultact.subsite

24
cultact.subsite Guido Stevens [email protected] www.cosent.nl Social Knowledge Technology

Upload: guido-stevens

Post on 05-Jul-2015

333 views

Category:

Technology


0 download

DESCRIPTION

Presentation at Plone Open Garden 2014 for the cultact.subsite content syndication toolkit. See source code + README at https://github.com/cosent/cultact.subsite

TRANSCRIPT

Page 1: Share content across subsites in Plone: cultact.subsite

cultact.subsite

Guido [email protected]

www.cosent.nlSocial Knowledge Technology

Page 2: Share content across subsites in Plone: cultact.subsite

Sharing Content between subsites

Page 3: Share content across subsites in Plone: cultact.subsite

Twin Sites

Page 4: Share content across subsites in Plone: cultact.subsite

Shared Content

Page 5: Share content across subsites in Plone: cultact.subsite

URL rewrites

# shared user folders

rewrite ^/profielen/$ /profielen permanent;

rewrite ^/profielen(.*) /VirtualHostBase/http/$server_name:80/ka/VirtualHostRoot/profielen$1 last;

# livesearch all content

rewrite ^/livesearch(.*) /VirtualHostBase/http/$server_name:80/ka/VirtualHostRoot/livesearch$1 last;

# serve subsite

rewrite ^/(.*) /VirtualHostBase/http/$server_name:80/ka/maastricht/VirtualHostRoot/$1 last;

Page 6: Share content across subsites in Plone: cultact.subsite

cultact.subsite

● request marking

● content containers

● assignment behavior

● catalog & collections

● canonical URL SEO

Page 7: Share content across subsites in Plone: cultact.subsite

Request Marking

● Inspired by plone.theme

● before_traverse hook maps request SERVERNAME to subsite

● request.set('in_subsite', chosen)

● Marks request with subsite-specific browser layer

So?● body class=”subsite_maastricht” CSS and Diazo rules

● Full custom theme registered for subsite layer possible

<drop css:theme=".only-subsite-maastricht" css:if-not-content="body.subsite-maastricht" />

Page 8: Share content across subsites in Plone: cultact.subsite

Content Containers

● dexterity.container

● Inspired by Lineage

● INavigationRoot

● ISite

● Very little content here

– subsite-local advertisements

– subsite-local contact info

Page 9: Share content across subsites in Plone: cultact.subsite

Assignment Behavior

● Dexterity behavior to map shared content to subsites

● subsite_home

– “main” subsite

– single choice

● subsite_syndication

– “default visible in” subsites

– multi choice

● Used to power browser query logic

– default: request.in_subsite in context.subsite_syndication

– other: request.in_subsite != context.subsite_home

Page 10: Share content across subsites in Plone: cultact.subsite

Catalog & Collections

● Catalog indexes

– subsite_home

– subsite_syndication

● Collection criteria

– subsite_home

– subsite_syndication

● MultisiteCollection behavior

– override Collection to not force INavigationRoot path query

Page 11: Share content across subsites in Plone: cultact.subsite

Misc Overrides

● override plone.app.layout.links.viewlets.CanonicalURL

– point to “home” subsite virtual URL for shared content

● override Products.Doormat viewlet

– show correct footer on shared content

– uses request marker to retrieve “right” Doormat

● Need to override search in your own custom code

Page 12: Share content across subsites in Plone: cultact.subsite

Sharing Content between subsites

Page 13: Share content across subsites in Plone: cultact.subsite

cultact.subsite

Guido [email protected]

www.cosent.nlSocial Knowledge Technology

Page 14: Share content across subsites in Plone: cultact.subsite

Sharing Content between subsites

Page 15: Share content across subsites in Plone: cultact.subsite

Twin Sites

Page 16: Share content across subsites in Plone: cultact.subsite

Shared Content

Page 17: Share content across subsites in Plone: cultact.subsite

URL rewrites

# shared user folders

rewrite ^/profielen/$ /profielen permanent;

rewrite ^/profielen(.*) /VirtualHostBase/http/$server_name:80/ka/VirtualHostRoot/profielen$1 last;

# livesearch all content

rewrite ^/livesearch(.*) /VirtualHostBase/http/$server_name:80/ka/VirtualHostRoot/livesearch$1 last;

# serve subsite

rewrite ^/(.*) /VirtualHostBase/http/$server_name:80/ka/maastricht/VirtualHostRoot/$1 last;

Page 18: Share content across subsites in Plone: cultact.subsite

cultact.subsite

● request marking

● content containers

● assignment behavior

● catalog & collections

● canonical URL SEO

Page 19: Share content across subsites in Plone: cultact.subsite

Request Marking

● Inspired by plone.theme

● before_traverse hook maps request SERVERNAME to subsite

● request.set('in_subsite', chosen)

● Marks request with subsite-specific browser layer

So?● body class=”subsite_maastricht” CSS and Diazo rules

● Full custom theme registered for subsite layer possible

<drop css:theme=".only-subsite-maastricht" css:if-not-content="body.subsite-maastricht" />

Page 20: Share content across subsites in Plone: cultact.subsite

Content Containers

● dexterity.container

● Inspired by Lineage

● INavigationRoot

● ISite

● Very little content here

– subsite-local advertisements

– subsite-local contact info

Page 21: Share content across subsites in Plone: cultact.subsite

Assignment Behavior

● Dexterity behavior to map shared content to subsites

● subsite_home

– “main” subsite

– single choice

● subsite_syndication

– “default visible in” subsites

– multi choice

● Used to power browser query logic

– default: request.in_subsite in context.subsite_syndication

– other: request.in_subsite != context.subsite_home

Page 22: Share content across subsites in Plone: cultact.subsite

Catalog & Collections

● Catalog indexes

– subsite_home

– subsite_syndication

● Collection criteria

– subsite_home

– subsite_syndication

● MultisiteCollection behavior

– override Collection to not force INavigationRoot path query

Page 23: Share content across subsites in Plone: cultact.subsite

Misc Overrides

● override plone.app.layout.links.viewlets.CanonicalURL

– point to “home” subsite virtual URL for shared content

● override Products.Doormat viewlet

– show correct footer on shared content

– uses request marker to retrieve “right” Doormat

● Need to override search in your own custom code

Page 24: Share content across subsites in Plone: cultact.subsite

Sharing Content between subsites