Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [page-controller]

The tag has no usage guidance.

0
votes
0answers
18 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
14 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
49 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\...
0
votes
0answers
45 views

How to upload a file to drupal using D8 Controller?

I am not using drupal as front end. Instead I am using drupal as backend. I want to upload a file into drupal files folder. Normal upload.php which we use is giving me an undefined $file error. I am ...
1
vote
1answer
74 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
43 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
28 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
29 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
36 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, ...
-1
votes
1answer
39 views

Page not found error when creating a simple module

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
198 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\...
0
votes
1answer
266 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
69 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
555 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
37 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
2k 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
85 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
44 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
1answer
346 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::...
3
votes
1answer
133 views

Custom page controller - Controller class not found

I have created a module called dino_roar, whose job is to create a web page. So i have created a dino_roar.routing.yml file which contains this: dino_says: path: /the/dino/says defaults: ...
2
votes
1answer
274 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
1k 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
386 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: &...
0
votes
1answer
950 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
288 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
107 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
371 views

Generate meta in drupal 8 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
318 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
326 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
1k 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
60 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 ...
0
votes
1answer
373 views

Create Custom page with custom blocks in Drupal 8

I just wanted to create a custom page with lots of custom block. For example an offer page, the offer contains multiple block with three Fields like name, image, description. The block must be dynamic ...
3
votes
1answer
66 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' =&...
0
votes
1answer
595 views

Iframe not displayed in Drupal 8 controller page

I have a controller page as follows: class ScenarioController extends ControllerBase { public function access_scenario() { $build = []; $build['body2'] = [ '#type' => 'markup', ...
1
vote
2answers
276 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
268 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
472 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->...
3
votes
2answers
383 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
2k 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
624 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
87 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
93 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
122 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
294 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 ...
0
votes
3answers
869 views

How do I redirect users to an external URL?

I implemented a controller class in Drupal 8, which redirects to an external site. If I use \Symfony\Component\HttpFoundation\RedirectResponse, I get this error. Redirects to external URLs are not ...
1
vote
1answer
727 views

Override page template and preserve administration navigation bar

Short version; I am trying to override the default page.html.twig (in D8) for a controller from my module and the following examples I've found have not worked: https://www.drupal.org/node/2499827 ...
2
votes
2answers
3k views

How can I add a custom form to the output of a controller class?

I have a controller in my custom module. Inside this controller I need to render a whole bunch of different things (some basic html, multiple forms, etc). My main problem is I can't figure out how ...
0
votes
0answers
154 views

Passing return values from controller into template

I am working on a Drupal 8 project and I am stuck on this. I am trying to pass my return values from controller to template. I created a search form page and I get bunch of different results related ...