I am required to build a Drupal module that collects data from an API and create a block on the page displaying the data in a specified format. I have downloaded and installed Drupal 8.0 Alpha2.
According to all the scattered un-infomal bits and pieces of information I have gotten I am really struggling to even see what I am trying to do.
Inside modules I have created a directory called custom and inside it placed a folder named "sidebar_currency".
The *.info.yml
I have created this file with its minimum requirements:
name: Sidebar Currency module
description: 'Exercise Module.'
package: Custom
hidden: false
type: module
core: 8.x
I added the hidden:false entry since I have been getting a "page not found" error.
The routing is as follows:
sidebar_currency.content:
path: '/currency'
defaults:
_controller: 'Drupal\sidebar_currency\Controller\SidebarCurrencyController::content'
_title: 'Sidebar Currency'
requirements:
_permission: 'access content'
In the controller entry I have tried to add a backslash before the Drupal namespace eg '\\Drupal\\sidebar_currency...'. This did not help at all.
Below is my structure of my module:
DRUPAL_INSTALL_DIR
|_ modules
|_ custom
|_ sidebar_currency
}_ src
|_ Controller
|_ SidebarCurrencyController.php
|_ sidebar_currency.info.yml
|_ sidebar_currency.routing.yml
|_ composer.json
Below is my controller which I would very much expect to see popping up something on my screen.
namespace Drupal\sidebar_currency\Controller;
use Drupal\Core\Controller\ControllerBase;
class SidebarCurrencyController extends ControllerBase
{
public function content()
{
return array(
'#type' => 'markup',
'#markup' => $this->t('List of currency'),
);
}
}
I am struggling to see this module in my Extend tab on the CMS except for all the rest of modules that have been pre-installed. I have clear all cache from the configuration menu and still cannot see anything.
Do I need to write my code inside sites instead of where it currently is sitting? Can somebody please help and point me to the right direction as to how I am suppose to go about doing this? Thanks in advance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.