Views Mini-Course, Part III: How to Back Up Your Views Safely

75
Part 3: Backing up your views! acquia.com 1 Wednesday, May 15, 2013

description

 

Transcript of Views Mini-Course, Part III: How to Back Up Your Views Safely

Page 1: Views Mini-Course, Part III: How to Back Up Your Views Safely

Part 3: Backing up your views!

acquia.com1Wednesday, May 15, 2013

Page 2: Views Mini-Course, Part III: How to Back Up Your Views Safely

Heather James Manager of Training at Acquia

HELLO!

@learningdrupal

@hjames

2Wednesday, May 15, 2013

Page 3: Views Mini-Course, Part III: How to Back Up Your Views Safely

Acquia Training

http://training.acquia.com3Wednesday, May 15, 2013

Page 4: Views Mini-Course, Part III: How to Back Up Your Views Safely

In todayʼs webinar!

• Views mini course - May 2nd: Introduction to Views- May 8th: How to build flexible views - May 15th: Build your first module to back up your views! <- Here!

• Drupal essentials!- May 22nd: Drupal Essentials: How to Configure Accounts in Drupal

• Drupal for Project Managers mini-course- May 29th-June 19th: 4 weeks - Drupal for Project Managers!

Adam Boysen, Jakub Suchy, Amye Scavarda, Jenn Sramek

4Wednesday, May 15, 2013

Page 5: Views Mini-Course, Part III: How to Back Up Your Views Safely

Notes online!

5Wednesday, May 15, 2013

Page 6: Views Mini-Course, Part III: How to Back Up Your Views Safely

What weʼre doing today

• Best practices to finish your view• Caching• Backing up views• If we have time: Theming Views - quick look!

6Wednesday, May 15, 2013

Page 7: Views Mini-Course, Part III: How to Back Up Your Views Safely

What you need to know already!

• How to add content• How to customize content types (add fields)• What modules are• How to install and configure modules

• From last week: How Views works, how to add a new View

7Wednesday, May 15, 2013

Page 8: Views Mini-Course, Part III: How to Back Up Your Views Safely

FINISHING YOUR VIEWS

Final checks

8Wednesday, May 15, 2013

Page 9: Views Mini-Course, Part III: How to Back Up Your Views Safely

Final checks

9Wednesday, May 15, 2013

Page 10: Views Mini-Course, Part III: How to Back Up Your Views Safely

Don’t forget! 1

2

34

65

710Wednesday, May 15, 2013

Page 11: Views Mini-Course, Part III: How to Back Up Your Views Safely

Views QA

http://www.zivtech.com/blog/views-quality-checklist11Wednesday, May 15, 2013

Page 12: Views Mini-Course, Part III: How to Back Up Your Views Safely

Disable the Views UI

• Finished? Disable the Views UI module.

12Wednesday, May 15, 2013

Page 13: Views Mini-Course, Part III: How to Back Up Your Views Safely

Tip!

• Enabled modules eat your memory. If it’s not in use- Disable it!

• If you’re never going to use it again, uninstall it, and remove from file system too!

13Wednesday, May 15, 2013

Page 14: Views Mini-Course, Part III: How to Back Up Your Views Safely

Caching

14Wednesday, May 15, 2013

Page 15: Views Mini-Course, Part III: How to Back Up Your Views Safely

All done?

• Enable caching to store query and output.

15Wednesday, May 15, 2013

Page 18: Views Mini-Course, Part III: How to Back Up Your Views Safely

What to cache

• Blocks

• Pages

• Don’t cache admin views.

• User bookmarks - places where people expect immediate response.

http://www.millwoodonline.co.uk/blog/drupal-7-performance-gains-with-views-cache

18Wednesday, May 15, 2013

Page 19: Views Mini-Course, Part III: How to Back Up Your Views Safely

Block cache type

19Wednesday, May 15, 2013

Page 20: Views Mini-Course, Part III: How to Back Up Your Views Safely

Block cache

20Wednesday, May 15, 2013

Page 21: Views Mini-Course, Part III: How to Back Up Your Views Safely

Debugging?

• Disable caching when debugging

21Wednesday, May 15, 2013

Page 22: Views Mini-Course, Part III: How to Back Up Your Views Safely

Demo

• Block and page cache settings under performance

• Views cache options!

22Wednesday, May 15, 2013

Page 23: Views Mini-Course, Part III: How to Back Up Your Views Safely

Smart cache option

• Views content cache

• http://drupal.org/project/views_content_cache

23Wednesday, May 15, 2013

Page 24: Views Mini-Course, Part III: How to Back Up Your Views Safely

EXPORT TO A MODULE

A better way

24Wednesday, May 15, 2013

Page 25: Views Mini-Course, Part III: How to Back Up Your Views Safely

Dangerous

• Views configuration is saved in the database.

• Editing a view on a live site

• Letting someone else edit the view on a live site.

• What if your precious View was ruined :(

25Wednesday, May 15, 2013

Page 26: Views Mini-Course, Part III: How to Back Up Your Views Safely

Quick and dirty: Export

26Wednesday, May 15, 2013

Page 27: Views Mini-Course, Part III: How to Back Up Your Views Safely

Import manually

27Wednesday, May 15, 2013

Page 28: Views Mini-Course, Part III: How to Back Up Your Views Safely

Demo

• Export code to a text file.

• Easy!

28Wednesday, May 15, 2013

Page 29: Views Mini-Course, Part III: How to Back Up Your Views Safely

Better: Export to module

• In code instead of storing them in the database.

• Can managed by your version control system - easier to push change from development to staging to production.

• Modest performance improvement due to loading from disk and not database.

http://www.deckfifty.com/blog/2012-02/using-drupal-views-code

Example code available at http://j.mp/ZhgWFn 29Wednesday, May 15, 2013

Page 30: Views Mini-Course, Part III: How to Back Up Your Views Safely

hook_views_default_views()

• http://api.drupal.org/api/views/views.api.php/function/hook_views_default_views/7

• Allows you to set a default view and configuration in code.

Example code available at http://j.mp/ZhgWFn 30Wednesday, May 15, 2013

Page 31: Views Mini-Course, Part III: How to Back Up Your Views Safely

Create a module

• Two text files

• deliciousdrupal.info

• deliciousdrupal.module

Example code available at http://j.mp/ZhgWFn 31Wednesday, May 15, 2013

Page 32: Views Mini-Course, Part III: How to Back Up Your Views Safely

Tip: Custom folder

• Custom modules?

• Add them in a “custom” folder.

• /custom

• /contrib

32Wednesday, May 15, 2013

Page 33: Views Mini-Course, Part III: How to Back Up Your Views Safely

Info file

• deliciousdrupal.info

Example code available at http://j.mp/ZhgWFn 33Wednesday, May 15, 2013

Page 34: Views Mini-Course, Part III: How to Back Up Your Views Safely

Module file

• deliciousdrupal.module

• Declare hook_views_api()

• You can paste the exported view directly, but that is messy.

34Wednesday, May 15, 2013

Page 35: Views Mini-Course, Part III: How to Back Up Your Views Safely

Easier to maintain: Includes

• Keep the includes in a separate folder

Example code available at http://j.mp/ZhgWFn 35Wednesday, May 15, 2013

Page 36: Views Mini-Course, Part III: How to Back Up Your Views Safely

Example code available at http://j.mp/ZhgWFn 36Wednesday, May 15, 2013

Page 37: Views Mini-Course, Part III: How to Back Up Your Views Safely

Easier to scale: Each view its own file

• Export each view and allow your module to scan for new views.

37Wednesday, May 15, 2013

Page 38: Views Mini-Course, Part III: How to Back Up Your Views Safely

Demo: Backup a new view

• Back up a view, adding to the module.

• 1. New text file - machine name of view.

• 2. Open with

• 3. Paste exported code

• 4. Save!

38Wednesday, May 15, 2013

Page 39: Views Mini-Course, Part III: How to Back Up Your Views Safely

Enable the module

Example code available at http://j.mp/ZhgWFn 39Wednesday, May 15, 2013

Page 40: Views Mini-Course, Part III: How to Back Up Your Views Safely

Backed up!

• Before:

• After - protected from deletion

40Wednesday, May 15, 2013

Page 41: Views Mini-Course, Part III: How to Back Up Your Views Safely

Clear cache

• Views > Settings > Advanced

41Wednesday, May 15, 2013

Page 42: Views Mini-Course, Part III: How to Back Up Your Views Safely

Database overriding code

• Indicates that it’s in code and also saved in database.

• Go to Views list to see your new views available.

• Click “Revert” to delete database copy.

42Wednesday, May 15, 2013

Page 43: Views Mini-Course, Part III: How to Back Up Your Views Safely

Changes?

• Working in staging site.

• Your colleague “edits” a view and tests changes.

• Export and save to your .views include files.

• Add new Views the same way:

• Export

• Add PHP declaration

• Save as .view in your includes folder

43Wednesday, May 15, 2013

Page 44: Views Mini-Course, Part III: How to Back Up Your Views Safely

Add a new view?

• Back up a view, adding to the module.

• 1. New text file - machine name of view.

• 2. Open with

• 3. Paste exported code

• 4. Save!

• 5. Clear cache! <-- now that module is already enabled.

44Wednesday, May 15, 2013

Page 45: Views Mini-Course, Part III: How to Back Up Your Views Safely

Recap

• Various states:

• “In database” - Not exported to code

• “Database overriding code”

• “In code” - No changes saved in database

• Actions:

• “Edit” - Create a copy in database with changes

• “Revert” - Delete from database

• “Disable” - Views in code can’t be deleted!

45Wednesday, May 15, 2013

Page 46: Views Mini-Course, Part III: How to Back Up Your Views Safely

Features

• This works the same way as Features.

• Basic module file

• Exported code

• This is what Features does for you automatically.

http://drupal.org/project/features

46Wednesday, May 15, 2013

Page 47: Views Mini-Course, Part III: How to Back Up Your Views Safely

THEMING VIEWS

47Wednesday, May 15, 2013

Page 48: Views Mini-Course, Part III: How to Back Up Your Views Safely

What you may expect

Mock up Design Comps

Configure and build

site

Drape over theme

Done!

48Wednesday, May 15, 2013

Page 49: Views Mini-Course, Part III: How to Back Up Your Views Safely

“Markup megalomaniac”

Design in static HTML

and CSS

Configure prototype

in core theme

Modify TPL to match original

markup

Configure to modify markup

Build style guide and reusable classes

Done!

49Wednesday, May 15, 2013

Page 50: Views Mini-Course, Part III: How to Back Up Your Views Safely

“Skeleton and skin”

Skeleton:Regions and

CSS for structure

Skin:CSS for visual

design

Done!

Content type design

Configure prototype

of site

Configure to modify markup

50Wednesday, May 15, 2013

Page 51: Views Mini-Course, Part III: How to Back Up Your Views Safely

Recap Views UI

1

2

5

43

6

51Wednesday, May 15, 2013

Page 52: Views Mini-Course, Part III: How to Back Up Your Views Safely

Example

• Recent comments View

52Wednesday, May 15, 2013

Page 53: Views Mini-Course, Part III: How to Back Up Your Views Safely

Anatomy of a View

View

That's great news! 50 min 32 sec ago

Oh I see, so even if i don't 4 weeks 52 min ago

Custom subject heading 4 weeks 53 min ago

Row

Title field

Date field

53Wednesday, May 15, 2013

Page 54: Views Mini-Course, Part III: How to Back Up Your Views Safely

Nested templatesDisplay

Format (style)

Field

Row

Field

Field

Row

Field

54Wednesday, May 15, 2013

Page 55: Views Mini-Course, Part III: How to Back Up Your Views Safely

View default output

• Depends on Views settings

55Wednesday, May 15, 2013

Page 56: Views Mini-Course, Part III: How to Back Up Your Views Safely

Configure to customize

• Modify format

• Specify elements

• Add classes

• Strip markup

• Strip default classes

• Make some fields inline

56Wednesday, May 15, 2013

Page 57: Views Mini-Course, Part III: How to Back Up Your Views Safely

Example

57Wednesday, May 15, 2013

Page 58: Views Mini-Course, Part III: How to Back Up Your Views Safely

Views base templates

58Wednesday, May 15, 2013

Page 59: Views Mini-Course, Part III: How to Back Up Your Views Safely

Example

59Wednesday, May 15, 2013

Page 60: Views Mini-Course, Part III: How to Back Up Your Views Safely

How can I find this?

60Wednesday, May 15, 2013

Page 61: Views Mini-Course, Part III: How to Back Up Your Views Safely

Which is being used?

61Wednesday, May 15, 2013

Page 62: Views Mini-Course, Part III: How to Back Up Your Views Safely

Display and format

62Wednesday, May 15, 2013

Page 63: Views Mini-Course, Part III: How to Back Up Your Views Safely

Template suggestions

• All fields (default)

• All fields just in blocks

• Any subject fields just in blocks

• Just subject fields in blocks in recent comments view

63Wednesday, May 15, 2013

Page 64: Views Mini-Course, Part III: How to Back Up Your Views Safely

Overriding

Copy into your theme folder and rename

64Wednesday, May 15, 2013

Page 65: Views Mini-Course, Part III: How to Back Up Your Views Safely

Rescan template files

65Wednesday, May 15, 2013

Page 66: Views Mini-Course, Part III: How to Back Up Your Views Safely

Next up!

• Check out the blog for notes from this 3 part class

• Drupal essentials- May 22nd: Drupal Essentials: How to Configure Accounts in Drupal

• Drupal for Project Managers mini-course- May 29th-June 19th: 4 weeks - Drupal for Project Managers! Adam

Boysen, Jakub Suchy, Amye Scavarda, Jenn Sramek

66Wednesday, May 15, 2013

Page 67: Views Mini-Course, Part III: How to Back Up Your Views Safely

Events! Learn in person

• http://acquia.com/events

• http://training.acquia.com/events

• http://dublin2013.drupaldays.org/

• http://www.drupical.com/

67Wednesday, May 15, 2013

Page 68: Views Mini-Course, Part III: How to Back Up Your Views Safely

VIEWS NEXT STEPS!Your assignment

68Wednesday, May 15, 2013

Page 69: Views Mini-Course, Part III: How to Back Up Your Views Safely

Your assignment

• Last week you made a view, right?

• This week:

• Add a display with an attachment

• Make a contextual filter or use a relationship

• Add a link to your menu

• Watch tutorials 4 parts, 5 mins each! http://www.drupalgardens.com/content/new-views-tutorials-4-part-intro

69Wednesday, May 15, 2013

Page 70: Views Mini-Course, Part III: How to Back Up Your Views Safely

Views webinar!

• Tips and Tricks for Getting the Most Out of Views [April 30, 2013]

• http://j.mp/mostviews

• Suzanne Kennedy, Evolving Web - one of our training partners.http://training.acquia.com/events/canada

• DrupalCon: Mastering Views Configuration

• http://portland2013.drupal.org/node/3718

70Wednesday, May 15, 2013

Page 72: Views Mini-Course, Part III: How to Back Up Your Views Safely

TRAINING!

72Wednesday, May 15, 2013

Page 73: Views Mini-Course, Part III: How to Back Up Your Views Safely

Course materials

• Tested in hundreds of classrooms.

• Continuously updated.• Clear and easy follow, but

engaging content. • Blend of guided and

challenge exercises to test skills.

http://training.acquia.com/courses

The materials / handouts were very

comprehensive - personally I would not

change anything.

- O.G. Jan 2012

73Wednesday, May 15, 2013

Page 74: Views Mini-Course, Part III: How to Back Up Your Views Safely

The trainers are partners

• Our trainers are experienced developers who love teaching.

• They provide subject matter expertise as well as well as passion for the topic.

• Partners are placed all over the globe.

http://training.acquia.com/testimonials

Lovely presenter, very patient and open to

questions. I feel a lot more confident to use

drupal myself and understand the

technical underpinnings.

- C.L., Sept 2012

74Wednesday, May 15, 2013

Page 75: Views Mini-Course, Part III: How to Back Up Your Views Safely

• Popular packages are typical examples of the tailored packages we have delivered.

Tailored courses available

http://training.acquia.com/events

[email protected]

75Wednesday, May 15, 2013