All Projects → renttek → magento2-virtual-controllers

renttek / magento2-virtual-controllers

Licence: MIT license
A module which enables developers to create virtual controllers in Magento 2

Programming Languages

PHP
23972 projects - #3 most used programming language
Makefile
30231 projects

Labels

Projects that are alternatives of or similar to magento2-virtual-controllers

module-stripe
Stripe Payments for Magento 2
Stars: ✭ 45 (+60.71%)
Mutual labels:  magento2
magento2-edit-order-email
Magento2 - Edit Order Email from Admin
Stars: ✭ 30 (+7.14%)
Mutual labels:  magento2
varnish-warmer-magento2
Magento2 module for handling Varnish cache (flushing, regenerating)
Stars: ✭ 55 (+96.43%)
Mutual labels:  magento2
m2.ProductAvailable
Magento2. Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
Stars: ✭ 31 (+10.71%)
Mutual labels:  magento2
international-telephone-input
Integration to Magento 2 a jQuery plugin for entering and validating international telephone numbers.
Stars: ✭ 26 (-7.14%)
Mutual labels:  magento2
magento
The Magento 2 MyParcel plugin
Stars: ✭ 20 (-28.57%)
Mutual labels:  magento2
OrderAttachment
Magento 2 Order Attachment by MagePrakash allows customers to attachments proof such as Images, PDFs or any type of Files/Docs while placing the orders.
Stars: ✭ 18 (-35.71%)
Mutual labels:  magento2
magento-2-pronko-consulting-theme
Pronko Consulting Theme for Magento 2
Stars: ✭ 47 (+67.86%)
Mutual labels:  magento2
magento2-module-url-data-integrity-checker
Magento 2 module which can find potential url related problems in your catalog data
Stars: ✭ 218 (+678.57%)
Mutual labels:  magento2
rapidez
Headless Magento - with Laravel, Vue and Reactive Search 🚀
Stars: ✭ 31 (+10.71%)
Mutual labels:  magento2
magento2-language-tr tr
Magento2 Turkish Translation / Magento2 Türkçe Çevirisi
Stars: ✭ 28 (+0%)
Mutual labels:  magento2
centminmod-magento2
Magento 2.2.2 Install Guide For Centmin Mod Nginx LEMP Stacks
Stars: ✭ 16 (-42.86%)
Mutual labels:  magento2
Magento-2-docker-configuration
Docker Configuration for Magento 2. Deploy secure, flexible and reusable docker infrastructure for Magento 2 in a matter of seconds.
Stars: ✭ 26 (-7.14%)
Mutual labels:  magento2
Brazilian-Solutions
Este repositório permite a discussão da comunidade brasileira Magento sobre módulos e soluções para o mercado brasileiro.
Stars: ✭ 19 (-32.14%)
Mutual labels:  magento2
sync-magento-2-migration
Release of rough proof of concept from 2018 that allows to import and export millions of products quickly
Stars: ✭ 51 (+82.14%)
Mutual labels:  magento2
magento2-Ho Import
No description or website provided.
Stars: ✭ 39 (+39.29%)
Mutual labels:  magento2
vsf-address-book
Customer address book extension for Vue Storefront - Integration to manage customer’s multiple addresses under my account section
Stars: ✭ 20 (-28.57%)
Mutual labels:  magento2
module-login-as-customer
Allows admin to login as a customer (enter to customer account).
Stars: ✭ 104 (+271.43%)
Mutual labels:  magento2
magento2-checkout-custom-form
Add a custom form to Magento 2 checkout.
Stars: ✭ 95 (+239.29%)
Mutual labels:  magento2
magento2-ansible-vagrant
Ⓜ️2️⃣ Ansible provisioned Ubuntu 16.04 vagrant box for Magento2 development.
Stars: ✭ 25 (-10.71%)
Mutual labels:  magento2

Renttek_VirtualControllers

Enables creating of routes with "virtual controllers"

Build Status Latest Stable Version License

What is a virtual controllers? A virtual controller is a path + an optional layout handle which will be set. With that it is possible to create custom routes where you can place custom blocks to your wishes. (In Magento 2 this is currently only possible by creating a route.xml & a dummy controller action, which returns a \Magento\Framework\View\Result\Page)

Comparison

Here is a short comparison of the minimal required code to create a custom route (example/page/view) in Magento 2 (given there is already a module My_Module)

Vanilla Magento 2

<module_dir>/etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="example" frontName="example">
            <module name="My_Module"/>
        </route>
    </router>
</config>

<module_dir>/Controllers/Page/View.php

<?php

namespace Mapa\Content\Controller\Page;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class View extends Action
{   
    private $resultPageFactory;
    
    public function __construct(Context $context, PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        return $this->resultPageFactory->create();
    }
}

With this Module

<module_dir>/etc/virtual_controllers.xml

<?xml version="1.0"?>
<controllers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Renttek_VirtualControllers:etc/virtual_controllers.xsd">
    <controller path="example/page/view" />
</controllers>

Features

Handles

Besides the much simpler creation of custom routes, every route will get a few layout handles set:

  • "default"
  • "virtual_controller"
  • The given path, but all characters except [a-z_] are replaced by underscores. (example/page/view => example_page_view)

The generated handle can also be set manually in the xml configuration like this:

<module_dir>/etc/virtual_controllers.xml

<?xml version="1.0"?>
<controllers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Renttek_VirtualControllers:etc/virtual_controllers.xsd">
    <controller path="example/page/view" handle="my_custom" />
</controllers>

Routes can also be disabled by setting disabled=true in the configuration:

<?xml version="1.0"?>
<controllers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Renttek_VirtualControllers:etc/virtual_controllers.xsd">
    <controller path="example/page/view" disabled="true" />
</controllers>

Forwards

Another feature is the possibility of creating forwards without creating a controller. Forwards are needed if you want to display another URL for a page. (e.g. 'my/shoppingcart' => 'checkout/cart')

<?xml version="1.0"?>
<controllers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Renttek_VirtualControllers:etc/virtual_controllers.xsd">
    
    <forward path="my/shoppingcart"
             module="checkout"
             controller="cart"
             action="index"/>
</controllers>

In V1 the attributes controller and action defaulted to 'index' if not specified. In V2 this is not the case!

Forwards are only URLs/path that CAN be called. It does not extend/manipulate url generation in any way.


All routes are merged by the path attribute, so it is possible to disable routes from other modules.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].