Amitai Burstein chia sẻ cách làm theming trong Drupal 7

Amitai Burstein chia sẻ cách làm theming trong Drupal 7

Treat your custom CSS as contrib

Getting your Drupal to be pixel perfect is hard. In fact, it's probably four times faster to write the logic of a page, in comparison to the time it takes to get it's markup right. Not to talk about making it responsive.

If you've seen my presentation about The Gizra Way you noticed we take pixel perfect very seriously.

One of the tools that helps us getting the markup fast, correct and in a way that would allow us to communicate with the client is Jekyll - the static site generator. Here's the idea in a nutshell:

  • Using Jekyll we can concentrate on a clean markup
  • Using Grunt we compile the SASS, and are able to push the the HTML into Github pages - where the client can easily see and interact with the final markup
  • The CSS produced by Jekyll is treated by our Drupal application as contrib. This means we have zero custom CSS in our theme. Seriously, absolutely no custom CSS in your Drupal theme!
  • Any change to the CSS can be done only in a single place, which is Jekyll

Implementation details

We use a great yo generator to build a Jekyll directory in our installation profile (obviously each project in Gizra is built as an installation profile). Here's an example of our Gruntfile.js. Note that if you are gonig to use Bootstrap, it still does't come out of the box, so you'll need to do somemanual work to set it up.

Our team can now work on the markup. Once the markup changes we can grunt deploy -- and the markup will be pushed to Github pages, to facilitate all the stake holders to validate the design and responsiveness of the site.

Next, when the team will work on the Drupal site, instead of coping the CSS into the Drupal theme itself, we copy it into libraries/custom (where "custom" could be your site's name). This means your CSS is edited only in a single place, which is the Jekyll app. Since this is a repetitive task we have automated it with a simple bash script.

Last step - given our custom theme is under profiles/[profile-name]/themes/custom/subtheme- is to load the "contrib" CSS via the theme's info file:

stylesheets[all][] = '../../../libraries/custom/css/main.css'

Finally, the developers can now enjoy working on a pixel perfect template where they only need to yank out the static parts and replace it with the dynamic content, so visually the site never looks broken, and logic is added to it incrementally.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Asus Zenbook UX21 “so găng” cùng Macbook Air 11.6 inch

Asus Zenbook UX21 “so găng” cùng Macbook Air 11.6 inch

Cầm trên tay dòng laptop Zenbook của Asus, thì rất dễ bị lầm lẫn với Macbook Air vì thiết kế nhôm unibody nguyên khối của nó, các cạnh được vát nhọn dần từ bản lề máy đến cạnh màn hình tương đối giống nhau.

Number 4: Infrastructure - 5 lỗi cần tránh trong Drupal

Number 4: Infrastructure - 5 lỗi cần tránh trong Drupal

In previous articles in this series, we’ve covered the areas of architecture, security and performance. All of these aspects are affected by your infrastructure from the time of development to deployment.

Ví dụ đơn giản về sử dụng PHPUnit và Drupal 8 năm 2015

Ví dụ đơn giản về sử dụng PHPUnit và Drupal 8 năm 2015

So, instead of duplicating what’s already out there, I’m going to focus on some principles 

Công ty diệt chuột T&C

 

Diet con trung