WSCCI Conversion Guide - Pass 1

1. Leverage the new routing system

First, we need to switch the declaration of the routes (the mapping rules) to the new routing system. The new routing system doesn't use a hook but a YAML file, book.routing.yml, that is placed in the root of the module directory.

book.routing.yml

book.render:
  path: '/book'
  defaults:
    _content: '\Drupal\book\Controller\BookController::bookRender'
  requirements:
    _permission: 'access content'

book.admin:
  path: '/admin/content/book'
  defaults:
    _content: '\Drupal\book\Controller\BookController::adminOverview'
  requirements:
    _permission: 'administer book outlines'

There's a lot going on here, so let's take it one step at a time.

Every route has a machine name. By default, using the name of the page callback function we're replacing is usually fine. Then there are three key sections for each route.

path
This is the path, what would have gone in the $items array as a key in hook_menu. Note that the path must begin with a / and may consist of not more than 9 parts each separated by a /. Also note that any placeholders are marked with {}, rather than %. More on that later.

WSCCI Conversion Guide

This guide is a basic tutorial for the process of converting legacy page callbacks to new-style controllers. It is not a guide for porting from Drupal 7 to Drupal 8; it assumes that you're working with a fairly recent copy of Drupal 8 HEAD. (A contrib module guide for porting from Drupal 7 to Drupal 8 can be based off of this document later.)

We will demonstrate the process by looking at the Book module in core. These are real-live examples (based on a true story!) of a core callback getting converted. Some snippets have been reformatted or tweaked to help illustrate a point. There are a lot of moving parts, so we'll take it in several passes and build up our understanding of what is going on. (This example taken directly from this issue.)

If you want to help with the conversion (please do!), see any issue with the WSCCI-Conversion tag or stop by #Drupal-WSCCI in IRC.

Forms not appearing

Hi,

I am in need of help. I did everything by the book, and yet one of my two forms doesn't appear and I'm not getting any tabs either. Manually browsing to the not-appearing form shows it. Non-problematic form is at http://drupalcode.org/project/tcmb.git/blob/3cb17d2:/lib/Drupal/tcmb/Tcm... and problematic one http://drupalcode.org/project/tcmb.git/blob/3cb17d2:/lib/Drupal/tcmb/Tcm.... Here is my routing.yml: http://drupalcode.org/project/tcmb.git/blob/3cb17d2:/tcmb.routing.yml. And just in case, my hook_menu implementation looks like

<?php
function tcmb_menu() {
$items['admin/config/system/tcmb-settings'] = array(
'title' => 'Tcmb General Settings',
'description' => 'Configure Tcmb module',
'route_name' => 'tcmb_currency_settings',
'weight' => 1,
);
$items['admin/config/system/tcmb-settings/currency-settings'] = array(
'title' => 'Currency settings',
'description' => 'Configure Tcmb currency settings',
'route_name' => 'tcmb_currency_settings',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
$items['admin/config/system/tcmb-settings/gold-settings'] = array(
'title' => 'Gold settings',
'description' => 'Configure Tcmb gold settings.',
'route_name' => 'tcmb_gold_settings',
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);

Upgrading D8 Nightly Builds

Hello all,

I've been using Drupal for some time now, and with building experience I'm finding myself starting websites from scratch to be quite regular :)

I'm just curious,

I understand D8 is unstable, but if I was building a site in D8 at the current time to be released after Drupal 8's official release, will I encounter any problems upgrading? I'm thinking more about the core improvements which change over time.
I'd like to build all I can when I can at the various stages of D8's development cycle, but I need assurance I will be able to pull it off.

drupal with windows and sql server

Hi

I am new to drupal. I want to build site with following features. would you please guide me if i can use drupal or not?

Learning Drupal

Greetings everyone!

First and foremost, I love drupal and its community.

Here's a brief description of who I am, where I am going, and what I am looking for from you folks.

- A few years ago I came up with an idea for a business.
- No experience with web development. I started with dreamweaver, got into php, watched videos from lynda.com, and then discovered the all mighty Drupal.
- Eventually got "stuck" with a few modules and customization. I tried educating myself and then decided it took too much time and I knew enough to describe what I wanted and hired some guys from India and the Phillipines. Huge language barrier. So I went to US developers, most of them were out of my budget and those that are cheap were a scam. I lost over $4000 so far...
- I recently decided to take this into my own hands, no matter how much time it takes, to learn drupal and php so that I can do this on my own.

Here are my specific issues with development.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 8.x