Stack Exchange Network

Stack Exchange network consists of 174 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
30 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 ...
-5
votes
0answers
32 views

How to override controller of a module in a custom module? [closed]

I need to override purl module controller in my custom module in the same admin path? There are 2 controller I need to override ModifiersController --admin/config/search/purl/modifiers ...
1
vote
1answer
30 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
26 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
24 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
24 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
35 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
35 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
53 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
94 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 ...
2
votes
1answer
390 views

How can I execute Drush commands programmatically? [duplicate]

I'm working on a site (D8), and part of the requirement is giving the client a page that they can click a button to do a particular task. I am able to do this using a Drush command using CLI. But I ...
0
votes
2answers
66 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
286 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
36 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 ...
0
votes
3answers
1k 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
68 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
220 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
81 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: ...
0
votes
1answer
89 views

Use elasticsearch in custom module

I'm trying to call the elasticsearch library inside of my controller, but it's not working. I just don't know how to call it from inside my code. I'm not exactly sure how to call an autoload inside of ...
2
votes
1answer
212 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
309 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
647 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
199 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
66 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
0answers
74 views

How to load a page inside modal bootstrap? [duplicate]

I'm looking for a way to dynamically load a page created using controller inside modal bootstrap. Any suggestion to achieve this is much appreciated? Thank you.
0
votes
0answers
33 views

Prepopulate programmatically Webform settings

I'm working on a Drupal tool to export / import contents from and to Drupal dashboard. I have to export CSV files with some datas (title, description, dates, etc.). These datas are well exported to ...
0
votes
2answers
306 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
2k 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
285 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
259 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
925 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
52 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
313 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
0answers
50 views

Controller or Form? (Drupal 8)

What circumstances would I use FormBase or ControllerBase? I can accomplish similar things with both but I do not entirely understand the use case for each.
0
votes
1answer
487 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
235 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
248 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
440 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
298 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
536 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
67 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
82 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
108 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
263 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
797 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 ...