Questions tagged [page-controller]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
50 views

Block not showing in controller generated tables Drupal 8

I have created a custom module that should show my custom block above the controller generated table. The block shows in other pages but not in the page where it is supposed to show. Found out that it ...
0
votes
1answer
20 views

How can I customize the header and footer from a custom page controller?

I have a module named some_module. This is my some_module.routing.yml: some_module.index: path: '/this/is/the/path' defaults: _title: 'Some Title' _controller: '\Drupal\some_module\...
3
votes
1answer
89 views

Using OAuth2 on non-REST endpoints

I have a custom module which includes a ControllerBase. The controller has a content() function that returns a JsonResponse(). The code for this function returns a complete list of a certain entity ...
4
votes
1answer
84 views

How to deal with Bubbleable Metadata when there's no rendering context and no render array

Since Drupal 8.0.0-beta12 "all rendering must happen in a render context", as stated by this change record. This is to avoid bubbleable metadata lost. So far, so good. Let's say I'm implementing a ...
1
vote
2answers
61 views

How to programmatically build a page and a form in the same page

What I'd like to do is build a page with two things: On one half of the page, custom markup with data from Drupal. On the other half, a custom form also submitted to Drupal. There are a lot of ...
0
votes
0answers
28 views

Format Json Responses as Camel Case

Currently our json responses are not formatted at all, we are using the JsonResponse class to return a status code with content: public function getMarkets() { $response = $this->...
0
votes
1answer
58 views

Why isn't my controller returning AccessResult::forbidden()?

I'm working on a node access module. I've set up my logic. I can't seem to get my code to return AccessResult::forbidden(). I can't even get \dpm to run in access method. What am I doing wrong? Below ...
0
votes
1answer
23 views

Permission denied for a route implemented by a custom module [closed]

Hello I have the same problem with the following code: first_module.routing.yml: first_module.content: path: '/first' defaults: _controller: 'Drupal\first_module\Controller\FirstController::...
0
votes
0answers
32 views

Trying to send data from client (JS) to server (D8) using jQuery.ajax [duplicate]

I'm new to D8 but have some D7 experience. I'm trying to receive some JSON data from the client and process it in my module. I have successfully received (I can break on it in my debugger) the ajax ...
0
votes
1answer
68 views

Pass argument when overriding controller in RouteSubscriber

I am having the issue of overriding the default taxonomy controller /taxonomy/term/{tid}. I have created my own controller which takes {tid} as a parameter and I want to use it instead, so I overrode ...
0
votes
0answers
81 views

How can I use a controller to render a form in a template file?

I'm looking to add a form inside a custom template. opacsearchmodule.routing.yml opacsearchmodule.route1: path: '/form-test/object-builder' defaults: _form: '\Drupal\opacsearchmodule\Form\...
1
vote
1answer
339 views

Creating a table with pagination in a Node Edit form

I have a content type article that has a field for Category. In order to help our editors find related articles, I included a table on the article Edit page that pulls in other article entities that ...
0
votes
1answer
117 views

Instantiate Controller with Interface not concrete class [closed]

As background, I am rebuilding some old code and want to wrap all the curl based requests in an interface (HttpRequestInterface) so I can swap that out later without having to write all the api calls ...
0
votes
1answer
35 views

Inject variables from Controller to Blocks?

I have a Product module that implement's an entity, a Repository, a Controller and 2 Blocks The problem is, in the product page, I'm querying the entity in every block and also in the Controller. I'm ...
0
votes
1answer
35 views

Render page with theme wrapper from custom controller?

I've created a page layout using panels in the Drupal admin UI (page_machine_id). I'm trying to load that page into a custom controller like so and render one of the variants (Drupal 8): public ...
0
votes
0answers
40 views

Assign a controller to all book pages

I am trying to build a module that checks if user session set in all pages of a certain book. if the session is not set it will be set. I am using a sso system so the user data will come from there, ...
-2
votes
1answer
159 views

Page not found error when creating a simple module [closed]

I have my first module in drupal 8 with three files in modules section of my drupal: hello_world.routing.yml: hello_world: path: '/hello/world' defaults: _controller: '\Drupal\...
1
vote
1answer
884 views

Creating iframe to be used in other websites

I've created a controller with the route "/get-info", the controller return a template custom-info.html.twig my_module/src/Controller/MyController.php file: <?php namespace Drupal\my_module\...
2
votes
1answer
1k views

How to send formatted html email using swiftmailer?

How can I send styled html body using custom module to send an email. I am using swiftmailer module. With that I am able to send normal body, but I am not able to use html tags or css. How can I do ...
0
votes
2answers
95 views

How do I pass a CSS class to the controller? [closed]

I want to pass a CSS class to a controller. In the case of nodes, I am using the following code. $node = \Drupal::routeMatch()->getParameter('node'); if ($node) { $variables['attributes']['...
-2
votes
1answer
2k views

How to create a dynamic front page [closed]

I have created page--front.html in drupal 8 custom theme then how to make dynamic this page section ? where I write custom code. i.e. how to showing slider images to which is added in admin side. ...
0
votes
1answer
42 views

How to set a url in drupal database or settings.php?

I had created a controller in custom module using drupal 8. public function subscribe(Request $request) { $url='https://username:password@someurl.com/v1/subscriptions'; } I am using git ...
1
vote
3answers
3k views

How to check whether a username already exists?

I had created a controller where I can create a new user programmitically by the following code. $user = User::create(); //Mandatory settings $user->setPassword($password); $...
1
vote
1answer
205 views

Edit a config variable of a custom module in controller

Is it possible to edit/create a config variable of a module in a controller created in the same module? For example: module_name/src/Controller/MyController.php: class MyController extends ...
0
votes
1answer
46 views

module controller does not respond!

I'm trying to create a controller within my custom module, but the controller still doesn't response when visiting the associated path. Here are my files: my_module/my_module.routing.yml: my_module....
0
votes
3answers
726 views

How to change payment state programmatically?

I had created a custom module to update order state and payment state. In my controller I used the following code to change the order state of order. $order = \Drupal\commerce_order\Entity\Order::...
2
votes
1answer
525 views

How to attach a library to a page controller that returns a plain Symfony response?

I created a custom module with a page controller that returns a Symfony response (Symfony\Component\HttpFoundation\Response). The thing is I don't want to render my custom theme in this controller, ...
0
votes
1answer
2k views

Get variable from controller in twig using template

I have a php variable in my controller and i want to use it in twig. So i do this : Controller : $firstLetter = '2017'; //dynamic variable but for the test it's a constant $build ['list'] = ...
0
votes
1answer
588 views

How to add a default controller to the <front> route?

Is it possible to add a default controller to the '<front>' route? There's no default controller defined in system.routing.yml. I'm trying to get a handle on it by using the following code: &...
1
vote
1answer
2k views

Render node from Controller

I have a controller that passes a list of nodes to a template for rendering. I think I'm missing something simple. I've tried this with no success: public function content() { $students = $this-&...
0
votes
1answer
534 views

Add JavaScript inside controller

How to add JavaScript inside controller? I don't want to call build form. I can call css or js in src/Form/Form.php but I want to call css or js inside Controller src/Controller/Controller.php This ...
0
votes
1answer
341 views

How to use 'use-ajax' class with pages created by controller?

I'm trying to use 'use-ajax' class to load a page inside a modal box. My Page is dynamically created using node id pass on my page controller My link looks like this Any idea on how can I achieve ...
0
votes
2answers
629 views

Generate meta in controller

I'm creating a custom module. This module displays public custom content without node and views . For this content custom page , I would like to add dynamic meta keyword and meta description . I ...
1
vote
2answers
3k views

Pass variables from controller to existing node template file

In the Drupal 8 documentation I have found a way how to pass variable from controller to custom twig template https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-...
0
votes
1answer
462 views

Drupal 8: Class not found from module Controller, but works fine from module EventSubscriber

I created a custom D8 module in: <root>/modules/custom/mymodule In that custom module are src/Controller/MyController.php and src/EventSubscriber/MySubscriber.php. I wrote some custom code ...
1
vote
1answer
622 views

Routing for controller with multilingual enabled

On my Drupal 8 multilingual project, I have made a custom controller which create a basic page, but I can't figure out which parameter I must use in the routing. Is this _locale? This is the ...
2
votes
1answer
2k views

How to render a custom entity in a controller?

I created a custom entity called foo. This entity has a unique name field as well as the standard id key. I would like to build a page where the user can see the entity rendered similarly to how it ...
0
votes
0answers
91 views

Tabledrag do not set values

I have a problem using page manager and tabledrag to change order of my blocks. When I place more than 20+ blocks, tabledrag stop working, one block has set "null" value in weight field. When I place ...
3
votes
1answer
70 views

How do I capture a page as HTML?

I have a controller that generates a custom 500 page. I have set up a route at the path: '/500'. I would like to capture this as HTML and save as a static file, so that I don't need to bootstrap ...
-1
votes
1answer
11 views

How to deny access to menu items that aren't expected

I want to find a way to make requests to hook_menu that I don't expect be denied. For example I have defined a menu like this: $items[$my_url] = array( 'title' => $my_title, 'page callback' =&...
1
vote
2answers
431 views

What is the best way to verify controller arguments?

For example, I have a path on my site. Let it be www.mysite.com/year/{year}/month/{month}/day/{day} Could you clarify me, what is the best way to avoid getting of wrong arguments, such as year/3000/...
1
vote
1answer
321 views

Render custom html below a custom form

I am new to drupal, I am using drupal 8, I have develop a custom form by extending FormBase controller and i am trying to render it using a custom controller like below. $form = $this->formBuilder-...
0
votes
1answer
598 views

How can i render webform on custom url with custom html in drupal 8

Basically I am using sample code which shown in below. public function test(){ $webform = \Drupal::entityTypeManager()->getStorage('webform')->load('contact_us'); $webform = $webform->...
2
votes
2answers
627 views

How do I define a route and controller for the home page?

A custom module called TSA contains almost all of the functionality for the /tsa subsite on my Drupal 8 multisite. I want to define a route for http://localhost/tsa/, so that I can serve up dynamic ...
2
votes
1answer
3k views

How do I pass parameters from a form redirect to a controller?

I feel like it should be easier to find this stuff out. I'm trying to pass some data from a form submission to a controller, and do something based on that data. What is the most Drupal way to do this ...
1
vote
4answers
848 views

How to debug a variable in a controller class (var_dump)

I am trying to do a var dump from a Drupal 8 Controller class. This is not working because controllers need to send a response. I just need to see the contents of a variable and I have not idea how to ...
1
vote
1answer
161 views

how to debug a controller not being run

my code below results in a page not found when I browse to the path. How can I debug what is going wrong? I dont see any errors and I have cleared the cache. mymodule.content: path: '/admin/...
1
vote
0answers
108 views

Redirect After Creating New Taxonomy Term

I am new to Drupal. I am trying to figure out if it is possible to redirect back to the Taxonomy page right after adding the new vocabulary term instead of being directed to the manage page of the ...
0
votes
1answer
157 views

Create a controller and a empty theme page

On Drupal 8, I'm looking for a way for creating an empty page (a page without any theme) that contains JavaScript code. I created a controller via Drupal Console, and I searched for an example on the ...
1
vote
0answers
364 views

One route, multiple controllers

How can I go around having a single route that would internally be forwarded to a controller depending on some internal logic. I've looked into dynamic routes but it doesn't help since the route is ...