Hiển thị các bài đăng có nhãn drupal. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn drupal. Hiển thị tất cả bài đăng

Thứ Sáu, 9 tháng 8, 2013

7 Mega Menu modules for Drupal

Mega menus (Multi Column Menus navigation) is web navigation menu which contain many customizable elements (like text, images, videos, slideshow...). You can easy create/find mega menu by using CSS and JavaScript, but what's about Drupal Modules? Below, you’ll find some of the Megamenu modules for your Drupal site.

MD Megamenu (added in 19th Jan 2013)

MD Megamenu
MD MegaMenu is a perfect choice for creating unique menus. You can create a vertical, horizontal or fixed responsive menu with many custom styles and effects. No coding required!. Simply drag and drop what you need into the places that you want.

OM Maximenu

OM Maximenu
"Maximize your main navigation by adding text, images, videos, slideshow, tabs, menu blocks, user info ..."
That is now possible by using OM Maximenu which can create menus with all other module blocks you want as attachments, modules like views, slideshow, menu, user, nice menus, quicktabs, and custom blocks with tables, lists, images, videos, etc.

Megamenu

Megamenu
This module allows you to build mega menus by leveraging jQuery and the existing Drupal menu system. Megamenu takes a Drupal menu that is 3 levels deep, and converts it into a categorized 3-level mega-dropdown-style menu, which can be placed into your theme as a block.

Superfish

Superfish
Superfish integrates jQuery Superfish plugin with your Drupal menus. This module support multi-column submenu like mega menu.

Menu Views (Drupal 7 only)

Menu Views
Menu Views allows administrators to attach a view inside a menu item.
This is useful when creating "mega-menus" with content such as:
  • Recent blog, node, or user posts
  • Complex views that contain graphics and other HTML structures.

MuchoMenu

MuchoMenu
This module allows users to create mega menus that have mini panels as their flyout content. The benefit is that ANY type of content or UI can be added to the menu flyouts.

Giga Menu

The Giga Menu module enables a standard Drupal menu to be displayed as a Mega Menu.

Menu Minipanels

There is a tremendous amount of configuration available via minipanels and almost anything can be added to one - views, blocks, nodes, other menus, and even raw PHP code if the PHP Filter is enabled. Further, there are multiple layouts available and more can be easily built. Further, each minipanel can be customized differently, so what do you think if you can add those minipanels to menu?

Mega Dropdown (sandbox)

Mega Dropdown module allows Drupal websites to display a menu a Mega Menu. It actually takes the concepts of the several other Mega Menus (also called Super Menus) such as Mega Menu, Giga Menu and Menu Minipanels, a step further. This module allows embedding of a Block, View, Node, or sub-menu items, on the menu. This enables placing, sub-menu content, images, text and even forms, on the menu system.
What modules do you like? Do you want new themes come with mega menu?

Thứ Năm, 25 tháng 7, 2013

How to create a customized front page in Drupal 7

#1


  • 1. Log into your Drupal 7 dashboard
  • 2. In the top menu, click Configuration
  • 3. Under System click Site Information
  • 4. Under FRONT PAGE, adjust the Default front page setting.
    setting-the-default-frontpage

    Be sure to pay attention to the following note if you want to disable this specific front page:
    Optionally, specify a relative URL to display as the front page. Leave blank to display the default content feed.
  • 5. Click the Save Configuration button at the bottom of the page to save these settings.

  • #2
    In this blog, I briefly describe a procedure for creating a customized Drupal front page. It’s just a series of steps of what to do, not a detailed how-to.
    1. Get into the theme directory: $Drupal7_Home/sites/all/themes/danland, where “danland” is the theme name.
    2. Copy and paste page.tpl.php into the same directory as it already is.
    3. Rename the copied file to page--front.tpl.php. Notice that there are two dashes.
    4. Change whatever you’d like to do for your customization in the page--front.tpl.php. For example, for a testing purpose, I change the phrase “Theme by” at the bottom of the page to “Developed by”.
    5. Clear Drupal caches:
      1. Open a web browser and point the address to your Drupal homepage such ashttp://localhost/drupal7
      2. Log into your Drupal homepage as administrator.
      3. Click on “Configuration”
      4. Then, under the “Development” section, click on “Performance”
      5. Finally, click on “Clear all caches”.
    6. Refresh your Drupal homepage, the “Theme by” at the button of the homepage should be changed to “Developed by”.


    Thứ Ba, 23 tháng 7, 2013

    my first multisite with shared users in drupal

    Here are steps for creating multisite with shared users that work for me please add any idea if you have
    you must know how to setup vhost in apache
    our domain for the site will be
    1. first install drupal normally (we will call the database for drupal installation drupaldb)
    2. after install drupal navigate to phpmyadmin or use mySQL gui tools and look for the database drupaldb (database you created previously )
      and look for these table
      'users' rename to 'shared_users',
      'sessions' rename to 'shared_sessions',
      'role' rename to 'shared_role',
      'authmap' rename to 'shared_authmap',
    use phpmyadmin or use mySQL gui to rename these table
    1. after rename these table of your database go to drupal installation folder and go to sites->default and edit settings.php as follow
    $db_url = 'mysqli://username:password@localhost/drupaldb';
    $db_prefix = array(
    'default' => '',
    'users' => 'shared_',
    'sessions' => 'shared_',
    'role' => 'shared_',
    'authmap' => 'shared_',
    );
    after edit save the file and refresh browser to see if the site (http://example.com) is working. if it work then we are good to go.
    1. Go to drupal installation folder and go to sites-> and create folder called site1.example.com and copy default.settings.php
      from sites->default and paste to new folder you created site1.example.com and rename default.settings.php to settings.php
    2. go to browser site1.example.com and install drupal as follow
      install drupal in database configuration type the same database you created inhttp://example.com which is drupaldb and in
      Advanced options on Table prefix: write site1_ and finish the installation.
    3. now go to sites->site1.example.com and edit settings.php as follow
    $db_url = 'mysqli://username:password@localhost/drupaldb';
    $db_prefix = array(
    'default' => 'site1_',
    'users' => 'shared_',
    'sessions' => 'shared_',
    'role' => 'shared_',
    'authmap' => 'shared_',
    );
    and save
    that it when you create user on example.com you will be able to see on site1.example.com
    do the same on site 3

    install new themes and modules of drupal in local

    You must be run command-line to change permission to www-data for your source code.

    chown www-data  -R drupal-7.22/

    Thứ Hai, 22 tháng 7, 2013

    Some Powerful Module for Views Drupal

    http://www.lunarclips.com/

    http://dev7studios.com/nivo-slider/

    http://demo.dev7studios.com/nivo-slider/

    Drupal 7. How to use Views module and edit/configure it (Full Version)

    This tutorial is going to show you how to use a Views module (its Views 3 revision) on your Drupal 7 website and edit/configure it.
    The Views module provides a flexible way to control the way lists and tables of content, users, taxonomy terms, photo galleries, slideshows etc are presented on your site. Each list managed by the views module is called a "view", and the output of a view is called a "display". With the help of the administrative interface the module allows you to pull nodes from the database and display them as you see fi t on your site.
    The module can be downloaded at http://drupal.org/project/views
    Once it is installed and enabled, go to the top menu Modules, scroll down to Views and make sure that Views and Views UI are checked.
    undefined
    Then go to Structure -> Views. On this page you can see the views that are already created (for instance, if you installed the template using the sample demo profile) and those yet to be activated if you click “enable” in the “Operations” column.
    undefined
    The best way to learn how this module works is to create a new View. On the same page, click “Add new view”.
    undefined
    Let’s say you want to create a list of Recent News embedded into to a block on your site.
    On the Add new view page you need to specify
    undefined
    • a unique View name (e.g. Recent News) and a machine name (cannot be changed once saved, e.g recent_news);
    • the View description to provide your view with a short administrative description, explaining what it does or where it is used (e.g A list of recent news);
    • Select what kind of site data should be displayed in the setting starting with Show (e.g. Content = nodes). You may also limit the view to display only certain content types (article, blog entry, gallery etc). You can also select how the view should be sorted.
    If you want your list to embedded into a page check Create a page. When checked, this option allows you to specify your new page title and the pathand to add a menu link to it right away.
    If you would rather like your view to be embedded into a block on a page, uncheck Create a page andcheck Create a blog. When checked, this option allows you to specify your block title. If you use this option, you can later find this block under Administration » Structure» Blocks.
    The both options allow you to select the Display format of your view and how many items you want to display on your page/block.
    undefined
    Scroll down to the bottom of the page and click Continue & Edit or Save & Exist (then you can find your view under Administration » Structure » Views).
    On the The Views edit page we recommend that you scroll down right away and check “Auto Preview” to be able to see the changes you are making.
    undefined
    Let us take a overlook at the display settings of the newly created view that we embedded into a blog you have there
    undefined
    For the view embedded into a page the settings are the same with the exception of a few fields:
    undefined
    If you click on “Add” next to the highlighted name of the current display, it will give you an option to add new displays of different types: attachment, block, feed and page. For one view you can have multiple displays.
    undefined
    To the right you can find another option to “edit view name/description” which as clicked allows you to
    • Change the name of the current view and change/ add a tag or description.
    • Analyze the view;
    • Clone view; When you click on the clone link on the upper right, all the options in the current view will copy to a new view, which can be given a new name and edited further.
    • Export view You can the copy and paste the code from a view into a module or something else. It is a array with all options for that view
    Let’s proceed to other options on this page:
    Display name (e.g. Blog or Page) allows you to change the name of the view to for admin needs, that is what you enter here will be not be visible to your site visitors.
    Then goes the Title of the blog/page etc with the option to change it. 
    Format shows the format that is currently selected (e.g. Html List). When clicked, it allows you to select a different way the content is formatted:
     undefined
    Click on “Settings”next to it in order to change them for the currently selected format. E.g.:
    undefined
    The Fields option allows you to select individual fields pulled from the content. Click “add” next to it to add additional fields.
    undefined
    To easily narrow down the results, the you can use the Search field. By having checked the fields you need, you can add as many as you need at a time.
    For the Recent News we are going to add the following:
    Content: Post date
    undefined
    Content: Body
    undefined
    Content: Link
    undefined
    Filter criteria gives you an option to determine which content specifically gets displayed. For example , if under the Filter criteria you have
    Content: Published (Yes). Content: Type (= Blog entry)
     undefined
    This means the option allows you to display only the Blog entries which are published. To add more of such criteria, click on “add”:
    The option Sort Criteria shows what way the data is currently sorted (e.g Content: Post date (desc) that means the date when the data was created and allows you configure it when clicked:
    undefined
    Click “add” to add more of such criteria.
    Block settings: iIf you sleeted the page option for your view, here you can set the path, select the menu item pointed to page with the current view and use and use the Access to specify permissions for certain types of users to allow them to access the view. 
    In case of a view embedded into a block, under the Settings you can specify the Block name and Access (user permissions).
    The Header and Footer options allows you to specify what content you want to show above and below the current view accordingly.
    Pager allows you to add a pager to your view of a specific type and specify how many items you want to use per page.
    More Link allows you to specify if the current display will provide a “more” link or not, if you are obviously not going to use the pager.
    Click on the Advanced to reveal different options to set Advanced configurations in your View:
    undefined
    • Contextual filters
    • The Ajax feature that allows you to enable/disable Ajax for the view (e.g. your site visitors can use the pagination and the page will not get refreshed every time).
    • Caching is recommended to be set to yes if your view has a great number of items  
    • Relationships
    • Exposed Form
    • others.
    When you are ready with your configuring the view, click the “Save” button at the top. Since in this example we have created a view embedded into a block , we need to go to the top menu Structure -> Blocks and locate the one that was created together with the view under Disabled
    e.g
    View: Recent news<
    Click on “configure” . Under the Region settings specify in which themes and regions this block is displayed. E.g. Bottom Content.
    Scroll down and click save block.
    Go to the page where you placed your click and check how the final result looks.
    You can continue modifying your view if you mouse over the top right corner of the content and select “Edit View”:
    undefined

    Add new regions in Drupal 7 themes


    Most Drupal themes have a number of pre-defined regions that you can use in your templates (.tpl.php) files. But what if you want to do something a bit more creative with your web site? For example, if you are using MD Minimal theme with only 3 block regions (highlight, help & content) and you need add social icons block in footer. So, here's a tutorial on how to create custom regions in your Drupal 7 themes.

    Step 1: define the custom region in your theme's .info file

    The .info file for your Drupal 7 theme will be located within the root of the theme's main folder. e.g. MD Minimal's .info theme file is located at: /themes/md_minimal/md_minimal.info
    Open up your theme's .info file and you should see some regions like this:

    regions[highlight] = Highlight
    regions[help] = Help
    regions[content] = Content
    

    to add a new region just type in a new one in md_minimal.info file.
    regions[footer_icons] = Footer icons
    

    Print out your new region in page.tpl.php file:

    <?php if ($page['footer_icons']): ?>
      <div class="footer-icons">
        <?php print render($page['footer_icons']); ?>
      </div> <!-- /.footer icons -->
    <?php endif; ?>
    

    Save file, clear your cache (go to admin/config/development/performance) and you will see the new region.

    Thứ Sáu, 19 tháng 7, 2013

    Drupal 7. How to use Views module and edit/configure it

    http://www.templatemonster.com/help/drupal-7-how-to-use-views-module-and-editconfigure-it.html

    http://www.templatemonster.com/help/files/Drupal/drupal_views_editing.htm


    You need Views if

    • You like the default front page view, but you find you want to sort it differently.
    • You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
    • You use /tracker, but you want to restrict it to posts of a certain type.
    • You like the idea of the 'article' module, but it doesn't display articles the way you like.
    • You want a way to display a block with the 5 most recent posts of some particular type.
    • You want to provide 'unread forum posts'.
    • You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
    Views can do a lot more than that, but those are some of the obvious uses of Views.

    những bước cơ bản để tạo theme trong Drupal 7

    Bài này sẽ hướng dẫn từng bước xây dựng 1 theme 

    Bắt đầu tạo theme

    1. tạo thư mục chứa theme

    Đầu tiên bạn cần tạo 1 thư mục chứa theme của bạn. Thư mục này nên đặt trong sites/all/themes haysites/yoursite/themes phụ thuộc vào bạn muốn theme của mình sẽ được sử dụng trong tất cả các site của bạn hay chỉ một site nào đấy. Hãy đặt tên duy nhất cho thư mục mô tả về theme của bạn.
    Ngoài ra, cũng cần thêm 2  thư mục con là images và CSS để chứa các file tương ứng. Điều này giúp dễ nhìn hơn cho người thiết kế. 2 thưc mục này nằm trong thư mục theme của bạn như sau: 
    • Theme name
      • css
      • images

    2. tạo tập tin .info

     từ drupal 6 về sau , tất cả các theme đều có tập tin .info , tập tin này chứa những thông tin cơ bản về theme.  Một số thông tin thì được sử dụng trong trang quản trị. bên cạnh đó nó cũng có những thành phần đặc biệt trong phần cấu hình cho theme (theme setting)
    file này đơn giản chỉ là file text bình thường với phần mở rộng là info. Tên của file nên trùng với tên theme của bạn. (ví dụ tên file là yourtheme.info thì tên bên trông mô tả nên là "yourtheme")
    Nội dung của file này nên có một số thành phần chính như sau
    name - Tên của theme
     description - mô tả sơ lược về theme
     core - phiên bản drupal mà theme tương thích
     engine - the templating engine mà theme sử dụng (có thể là phptemplate)
     regions - những vùng trên giao diện mà ở bài trên đã phân tích. Tên vùng dành cho hệ thống hiểu sẽ được viết trong 2 dấu ngoặc vuông "[ ]" (ví dụ như  regions[sidebar_first]). phần này dùng để chèn những vùng trong file template. Tên được đặt ở đây sẽ được sử dụng cho tên các vùng trong phần bố trí block  của giao diện.
     Trong drupal 7 phải bao gồm  vùng content để tùy chỉnh cho những vũng khác mà bạn cầ. Và cũng nên sử dụng những tên chuẩn cho những vùng sidebar như ("sidebar_first" va  "sidebar_second" trongDrupal 7). ở đây cũng nên  enable Drupal để thêm những vào trong <body> để chỉ định sidebar nào được sử dụng (no-sidebars, sidebar-right, sidebar-left).
     features - các thành phần của theme.  tính năng này có thể bật hay tắt trong giao diện của admin ví dụ như chỉ định về tên của site, trạng thái, logo.....) Chỉ những đặc tính list trong file info thì mới có tác dụng trong trang admin và tùy biến trong template của trang .Nếu bạn muốn xóa tắt cả các feature thì nên để trống ở đây.

    Sử dụng tùy chỉnh  những cấu hình cho theme(features)

     

    Một vài thành phần được chỉ định trong từ khóa feature có thể không cần thiết cho theme của bạn. Mặc định, các block sẽ có tác dụng trong các menu điều khiển chuẩn là ( main menu và secondaru menu. giao diện sẽ tự lấy tập tin favicon.ico trong thư mục theme của bạn. nếu không thích, có thể viết code cho phần hình của logo trong theme của bạn thay vì sử dụng qua giao diện upload của admin.
    Một số việc cần làm :
    1. viết lệnh cho một số biến trong template file và /hoặc
    2. Cho phép người dùng tùy chỉnh chúng trong admin.
    Trong phần logo và favicon thì nên thiết kế form cho upload lên nếu bạn muốn dể dàng thay đổi.
    Nhiều theme có rất nhiều thành phần tùy chỉnh (ví dụ như  theme  Bartik và Garland ). Nếu thật sự thấy cần thiết thì nên làm điều này
    stylesheets - những tập tin CSS . cú pháp chính như sau (ví dụ  stylesheets[all][] hay stylesheets[print][])
     scripts - các file script (javacript/js...)mà bạn sử dụng (chú ý drupal đã có sẳn jQuery, vì thế bạn không cần thêm ở đây)
     Các tập tin CSS và JS được đặt trong thư mục tương ứng của theme thì càng tốt. Điều này giúp dễ quảnl ý hơn
    đây là một ví dụ của file.info :

    name = My Cool Theme
    description = Custom theme for my site
    core = 7.x
    engine = phptemplate
    regions[header] = Header
    regions[sidebar_first] = Right sidebar
    regions[content] = Content
    regions[footer] = Footer
    stylesheets[all][] = css/style.css
    stylesheets[print][] = css/print.css
    features[] = name
    features[] = main_menu


     3. Tìm hiểu thêm về file template

    giao diện của drupal dựa trên chính vào các file template, có phần mở rộng là .tpl.php. Những file này chứa HTML  và những biến giá trị để lấy những thông tin từ drupal
    Nếu muốn tạo 1 theme đơn giản, bạn thật sự không cần một file template nào cả. theme chỉ cần có CSS cũng đã đủ. Drupal sẽ dùng template chuẩn cho tất cả những code được viết ra.  Những mặt định gồm có cả những module được phát sinh của một thành phần bất kỳ trong nội dung. Ví dụ , mặc định cho một node  drupal sẽ lấy từ module node như là node.tpl.php. HTML cho block cũng vậy sẽ được lấy từ module block trong block.tpl.php
    Bạn cũng chỉ cần tạo những  tập tin template cần thiết cho theme của bạn nếu muốn thay đổi so với mặc định, những phần khác  sẽ được tự động đưa vào. Tuy nhiên chú ý không bao giờ thây đổi vào core của drupal. Chỉ nên sử dụng những phương thức để overriding  chuẩn thôi.
    để an toàn thì nên copy những tập tin theme từ module chuẩn và thêm vào trong thư mục theme của mình.  đọc  thêm về module  theme developer.
     Một tập tin template quan trong mà sẽ làm việc nhiều là  page.tpl.php. tập tin này chứ code cho phần chính của trang . tập tin này mặc định trong module system.  Mặc định thì tập tin này chứa rất nhiều code có thể không cần vì thế phần này sẽ có hướng dẫn để viết từ đầu.
    Ngoài ra trong drupal 7 cũng có tập tin html.tpl.php, nó bao gồm  nhiều cấu trúc của trang. (đó là những phần như <head>, các tag mở đống <body> <html>). Thật sự chúng ta không quan tâm nhiều đến file này vì nó không có nhiều code. Vì thế muốn thay đổi gì thì nên tạo riêng ra 1 file trong thư mục theme của mình.
    Bay giờ bắt đầu tìm hiểu về cấu trúc của page.tpl.php

    3.1 tạo tập tin page.tpl.php

     Tạo mới tập tin có tên là page.tpl.php.  Tập tin này chứa tất cả các code cho phần body chính của theme. nó bao gồm:
    1. Các lệnh HTML cho theme(gồm cả các div và bất cứ thành phần chính của cấu trúc)
     2. Định nghĩa các vùng
    3. Bient61 cho các thành phần của nội dung (ví dụ như title(tiêu đề), các navigation tabs)

    đây là một file HTML đơn gian
    <div id="header">

    </div>
    <div id="wrapper">
      <div id="content">
      </div>
      
      <div id="sidebar">
      </div>
    </div>
    <div id="footer">
    </div>


    3.2 Tạo các vùng


    Các phần trong trang sẽ có thể được điều chỉnh thông qua giao diện của block với tên đại diện là các vùng (region). Trong trang mẫu ở trên bao gồm header, right sidebar,  content area, và footer. Chú ý các vùng này phải được mô tả trong file .info.
     Thật sự thì bạn không cần định nghĩa các vùng này cũng được vì drupal sẽ tự thêm vào. Ở đây gồm có header, highlighted, help, content, sidebar_first và sidebar_second.
     Trong drupal 7, biến gồm cả vùng được đưa vào sử dụng  trong  Render Arrays. THật sự thi bạn không cần hiểu hết tất cả thành phần này ngay bây giờ,  bạn chỉ cần hiểu 1 vài thành phần cho điều chỉnh ở đây thôi. Sẽ có một bài khác nói về vấn đề này.
    Trong theme sẽ có những lúc các vùng không có nội dung, vì vậy cần phải quản lý lúc có thì thể hiện còn nếu không có thì không thể hiện ra. Cần thêm code để kiểm tra và thể hiện như sau
    Đây là  ví dụ cho việc kiểm tra xem phần region footer có hay không có để thể hiện, trong file info có định nghĩa region là footer vì thế sử dụng tên footer để kiểm tra thông qua biến $page['footer']) (chú ý tên footer là tên phần máy hiểu(năm trong ngoăc vuông))

    <?php if ($page['footer']): ?>  
      <?php print render($page['footer']); ?>
    <?php endif; ?>
     Thực hiện tiếp cho các phần con lại của theme

    Ngoài ra, khi định nghĩa div trong giao diện thì nếu region này không có thì bạn có muốn hiển thị ra hay không?
     đây là file  page.tpl.php đã định nghĩa xong:

    <div id="header">
    </div>
    <div id="wrapper">

      <div id="content">
        <?php print render($page['content']); ?>
      </div>
      <?php if ($page['sidebar_first']): ?>  
        <div id="sidebar">
          <?php print render($page['sidebar_first']); ?>
        </div>
      <?php endif; ?>
    </div>
    <div id="footer">
      <?php if ($page['footer']): ?>  
        <?php print render($page['footer']); ?>
      <?php endif; ?>
    </div>

    3.3 Thêm biến cho những thành phần cơ bản của trang

     Có rất nhiều phần sẽ không tồn tại trong region. ở phần này sẽ hướng dẫn cách thêm các biến cho các thành phần chính của trang, gồm tiêu đề trang và các navigation tabs. như mô tả ở trên thì có rất nhiều biến trong drupal có tác dụng trong page.tpl.php. Phụ thuộc vào những chức năng gì mình muốn trong theme. Ví dụ bạn có muốn breadcrumbs. nếu muốn thì thêm biến $breadcrumbs vào:
     Một số biến như sau :

    • $site_name
    • $logo (đây là biến được sử dụng thông qua chức năng upload của trang admin và phần feature định nghĩa trong info)
    • $title (tiêu đề trang)
    • $main_menu
    • $secondary_menu
    • $breadcrumbs
     thêm một số biến  chỉ có trong phần quản trị của drupal
    • $tabs (menu used for edit/view admin menus, among other things; often used by modules)
    • $messages
    • $action_links

    và đây là một số biến rất thường dùng 
    • $base_path (đường dẫn chính của site)
    • $front_page (đường dẫn chính đến trang chủ)
    • $directory (đường dẫn chính đến theme)

    biến chèn vào thì sử dụng hàm của  Render API, giống như sau:
     <?php print render($tabs); ?>

    Một chú ý cho phần menu và điều chỉnh cấu hình theme


    những menu điều khiển (navigation menu) như là main menu và  secondary menu thì mặc định cũng có những biến tương ứng. Vì thế có thể chèn vào trong template dưới dạng code. Còn nếu muốn tùy biến giao diện thì sau này sẽ tùy chỉnh trong block cũng được. Tùy bạn. Vấn đề tương tự cho phần logo cũng vậy... có thể viết trực tiếp trong code luôn hoặc tùy chỉnh trong chức năng của  giao diện admin
    Nếu mục đích muốn giao diện có khả năng khả chuyển cho nhiều site khác nhau thì vấn đề tùy chỉnh được của menu và logo là cần thiết. Còn nếu thiết kế site cho khách hàng và không muốn họ can thiệp qua nhiều vào tính năng này để thay đổi thì bạn nên cứng hóa trong code.
    Một điểm quan trong nữa là những liên hết đến menu thì trả về là một mảng. Khi viết vào trong template, cần phải tách từng thành phần thông qua hàm  theme() để thể hiện:
    <?php if ($main_menu): ?>
      <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu'))); ?>
    <?php endif; ?>

    Ở trong bài này tôi chèn logo thông qua  <img>, chứ không dùng biến $logo , Vì tôi không muốn upload logo qua giao diện admin. vì cần tập trung vào sử dụng vào các biến như $base_path, $directory, và $site_name.
     chú ý trong drupal 7 thì có 2 biến$title_prefix và $title_suffix. Nhiều module có thể sử dụng nó, nên chú ý khi sử dụng chúng trong theme.
     Một điều nữa là mộtso61 biến được thể hiện ra giao diện thông qua hàm render(). Trong khi các  thành phần khác lại  thông qua print.  bạn thấy khác biệt như thế nào?  nếu có biến trong mảng (xem danh sách trong page.tpl.php reference page)  nên dùng render(). Ngoài ra sử dụng hàm print (<?php print $variable; ?>). nếu gặp trục trặc hay xem file mặc định  page.tpl.php để xem chúng sử dụng như thế nào.
     đây là tâp tin page.tpl.php của tôi trong bài hướng dẫn này :

    <div id="wrapper">
      <div id="header">
        <a href="<?php print $front_page;?>">
          <img src="/<?php print $directory;?>/images/logo.png" alt="<?php print $site_name;?>" height="80" width="150" />
        </a>

        <?php if ($main_menu): ?>
          <?php print theme('links', $main_menu); ?>
        <?php endif; ?>
      </div>

      <div id="content">
        <?php print render($title_prefix); ?>
          <?php if ($title): ?><h1><?php print $title; ?></h1><?php endif; ?>
        <?php print render($title_suffix); ?>
        <?php print render($messages); ?>
        <?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
        <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
        <?php print render($page['content']); ?>
      </div>
      <?php if ($page['sidebar_first']): ?>  
        <div id="sidebar">
          <?php print render($page['sidebar_first']); ?>
        </div>
      <?php endif; ?>  
      <div id="footer">
        <?php if ($page['footer']): ?>  
          <?php print render($page['footer']); ?>
        <?php endif; ?>
      </div>
    </div>

    4. xây dựng CSS

     Bước này thì tôi không cần nhắc vì bạn đã có kinh nghiệm về CSS...

    5. thử nghiệm nào!

     Bây giờ thì trang mẫu đã được tạo, vào trong phần appearance để enable nó lên. sau đó vào xóa cache trong Site Configuration > Performance

    6. Create your screenshot

     Tạo một hình ảnh cho phần  screenshot  với kích cở là 150x90, ađặt nó vào trong thư mục theme của bạn. tên nên làscreenshot.png

    Download theme files


    đây là file đã làm xong ở đây: mycooltheme.tar.tz.

    Học lập trình web căn bản với PHP

    Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...