Views Mini-Course, Part III: How to Back Up Your Views Safely
-
Upload
acquia -
Category
Technology
-
view
1.806 -
download
1
description
Transcript of Views Mini-Course, Part III: How to Back Up Your Views Safely
Part 3: Backing up your views!
acquia.com1Wednesday, May 15, 2013
Heather James Manager of Training at Acquia
HELLO!
@learningdrupal
@hjames
2Wednesday, May 15, 2013
Acquia Training
http://training.acquia.com3Wednesday, May 15, 2013
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
Notes online!
5Wednesday, May 15, 2013
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
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
FINISHING YOUR VIEWS
Final checks
8Wednesday, May 15, 2013
Final checks
9Wednesday, May 15, 2013
Don’t forget! 1
2
34
65
710Wednesday, May 15, 2013
Views QA
http://www.zivtech.com/blog/views-quality-checklist11Wednesday, May 15, 2013
Disable the Views UI
• Finished? Disable the Views UI module.
•
12Wednesday, May 15, 2013
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
Caching
14Wednesday, May 15, 2013
All done?
• Enable caching to store query and output.
15Wednesday, May 15, 2013
Site caching basics
• Set lifetime to minimum 5 minutes.
• Will your content editors freak out?
https://www.acquia.com/blog/when-and-how-caching-can-save-your-site-part-2-authenticated-users
16Wednesday, May 15, 2013
Save your site
• Read Hernani’s blog posts!
https://www.acquia.com/blog/when-and-how-caching-can-save-your-site-part-2-authenticated-users
17Wednesday, May 15, 2013
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
Block cache type
19Wednesday, May 15, 2013
Block cache
20Wednesday, May 15, 2013
Debugging?
• Disable caching when debugging
21Wednesday, May 15, 2013
Demo
• Block and page cache settings under performance
• Views cache options!
22Wednesday, May 15, 2013
Smart cache option
• Views content cache
• http://drupal.org/project/views_content_cache
23Wednesday, May 15, 2013
EXPORT TO A MODULE
A better way
24Wednesday, May 15, 2013
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
Quick and dirty: Export
26Wednesday, May 15, 2013
Import manually
27Wednesday, May 15, 2013
Demo
• Export code to a text file.
• Easy!
28Wednesday, May 15, 2013
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
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
Create a module
• Two text files
• deliciousdrupal.info
• deliciousdrupal.module
Example code available at http://j.mp/ZhgWFn 31Wednesday, May 15, 2013
Tip: Custom folder
• Custom modules?
• Add them in a “custom” folder.
• /custom
• /contrib
32Wednesday, May 15, 2013
Info file
• deliciousdrupal.info
Example code available at http://j.mp/ZhgWFn 33Wednesday, May 15, 2013
Module file
• deliciousdrupal.module
• Declare hook_views_api()
• You can paste the exported view directly, but that is messy.
34Wednesday, May 15, 2013
Easier to maintain: Includes
• Keep the includes in a separate folder
Example code available at http://j.mp/ZhgWFn 35Wednesday, May 15, 2013
Example code available at http://j.mp/ZhgWFn 36Wednesday, May 15, 2013
Easier to scale: Each view its own file
• Export each view and allow your module to scan for new views.
37Wednesday, May 15, 2013
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
Enable the module
Example code available at http://j.mp/ZhgWFn 39Wednesday, May 15, 2013
Backed up!
• Before:
• After - protected from deletion
40Wednesday, May 15, 2013
Clear cache
• Views > Settings > Advanced
41Wednesday, May 15, 2013
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
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
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
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
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
THEMING VIEWS
47Wednesday, May 15, 2013
What you may expect
Mock up Design Comps
Configure and build
site
Drape over theme
Done!
48Wednesday, May 15, 2013
“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
“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
Recap Views UI
1
2
5
43
6
51Wednesday, May 15, 2013
Example
• Recent comments View
52Wednesday, May 15, 2013
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
Nested templatesDisplay
Format (style)
Field
Row
Field
Field
Row
Field
54Wednesday, May 15, 2013
View default output
• Depends on Views settings
55Wednesday, May 15, 2013
Configure to customize
• Modify format
• Specify elements
• Add classes
• Strip markup
• Strip default classes
• Make some fields inline
56Wednesday, May 15, 2013
Example
57Wednesday, May 15, 2013
Views base templates
58Wednesday, May 15, 2013
Example
59Wednesday, May 15, 2013
How can I find this?
60Wednesday, May 15, 2013
Which is being used?
61Wednesday, May 15, 2013
Display and format
62Wednesday, May 15, 2013
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
Overriding
Copy into your theme folder and rename
64Wednesday, May 15, 2013
Rescan template files
65Wednesday, May 15, 2013
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
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
VIEWS NEXT STEPS!Your assignment
68Wednesday, May 15, 2013
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
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
Views tutorials
• Quick version: 4 parts, 5 mins each! http://www.drupalgardens.com/content/new-views-tutorials-4-part-intro
• Drupalize.me http://drupalize.me/videos/overview-views
• 10 part series with “Toronto Web Developer”http://j.mp/Zc8nEO
71Wednesday, May 15, 2013
TRAINING!
72Wednesday, May 15, 2013
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
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
• Popular packages are typical examples of the tailored packages we have delivered.
Tailored courses available
http://training.acquia.com/events
75Wednesday, May 15, 2013