magento2 – Magento 2 how to create custom index.php and pass store code programmatically?

I have a multi-vendor e-commerce platform, everytime I create a new store I need to create a folder for the store and include an index.php

for example:


Inside the index.php I add the store code like this:

$params = $_SERVER;
$params(MagentoStoreModelStoreManager::PARAM_RUN_CODE) = 'store2_code'; //this is the important line
$params(MagentoStoreModelStoreManager::PARAM_RUN_TYPE) = 'store';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params);
/** @var MagentoFrameworkAppHttp $app */
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');

How could I programmatically create an index.php file and add the store code?
Currently I know how to create the store programmatically, but just the index.php is missing.


8 – How to pass a field value as contextual filter argument using Twig Tweak drupal_view?

In Drupal 8, I’m using Twig Tweak to embed a view. I have a contextual filter set to one of the node’s fields, field_project_id. If I use a literal for the third argument, it works. If I try to reference the value of the current node’s project ID, no luck.


{{ drupal_view('my_view', 'block_1', '2011-40054-000') }}  

Doesn’t work:

{{ drupal_view('my_view', 'block_1', content.field_project_id) }},  
{{ drupal_view('my_view', 'block_1', content.field_project_id.value) }},  
{{ drupal_view('my_view', 'block_1', content.field_project_id.0) }},  
{{ drupal_view('my_view', 'block_1', content.field_project_id.0.value) }},  


What’s the proper way to do this?

c++ – How to pass std::map by reference to std::thread?

I have a std::map I want to pass by reference to std::thread:

void estConnection(int sockfd, map<int,sockaddr_in> &clients, string document){

int main(){
    map <int, sockaddr_in> clients;
    std::thread th(estConnection, sockfd, std::ref(clients), document);

compiler (c++ main.cpp -o main) throws next error:

/usr/bin/ld: /tmp/ccJyzdF0.o: in function std::thread::thread<void (&)(int, std::map<int, sockaddr_in, std::less<int>, std::allocator<std::pair<int const, sockaddr_in> > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), int&, std::reference_wrapper<std::map<int, sockaddr_in, std::less<int>, std::allocator<std::pair<int const, sockaddr_in> > > >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, void>(void (&)(int, std::map<int, sockaddr_in, std::less<int>, std::allocator<std::pair<int const, sockaddr_in> > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), int&, std::reference_wrapper<std::map<int, sockaddr_in, std::less<int>, std::allocator<std::pair<int const, sockaddr_in> > > >&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': server.cpp:(.text._ZNSt6threadC2IRFviRSt3mapIi11sockaddr_inSt4lessIiESaISt4pairIKiS2_EEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEJRiSt17reference_wrapperIS9_ERSG_EvEEOT_DpOT0_(_ZNSt6threadC5IRFviRSt3mapIi11sockaddr_inSt4lessIiESaISt4pairIKiS2_EEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEJRiSt17reference_wrapperIS9_ERSG_EvEEOT_DpOT0_)+0x4f): undefined reference to pthread_create’ collect2: error: ld returned 1
exit status

The goal is to add a new value to map.
What am I doing wrong and how to solve this issue ?

magento2 – How to pass parameter from phtml template file to controller in Magento 2

I have created a custom module. It basically displays a popup modal that prompts user to enter their ship-to location.

Below is my code:


<?xml version="1.0"?>

<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Learning_ShiptoModal">
            <module name="Magento_Theme"/>


<?xml version="1.0"?>
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="footer-container">
            <!-- <block name="shipto.modal.wrapper" template="Vistar_ShiptoModal::shipto-prompt.phtml" class="MagentoFrameworkViewElementTemplate">
                <block class="MagentoCmsBlockBlock" name="shipto-modal">
                        <argument name="block_id" xsi:type="string">shipto-modal</argument>
                        <argument name="default_states_view_model" xsi:type="object">VistarShiptoModalViewModelDefaultStatesViewModel</argument>
            </block> -->
            <block class="MagentoFrameworkViewElementTemplate" name="shipto-modal" template="Vistar_ShiptoModal::shipto-prompt.phtml">
                    <argument name="default_states_view_model" xsi:type="object">VistarShiptoModalViewModelDefaultStatesViewModel</argument>


 * @copyright Copyright (c) Vistar 
$viewModel = $block->getDefaultStatesViewModel();

<div id="vistar-shipto-modal">
    Please enter your ship to location:
    <span><?= $viewModel->getStates() ?></span>

    require(('Vistar_ShiptoModal/js/shipto-modal', 'domReady!'),function(){})


var config = {
    map: {
        '*' : {
            learningShiptoModal : 'Learning_ShiptoModal/js/shipto-modal'


function($, modal) {
    //Use cookie to display modal just once 
    //Display modal if no cookie is present
    const DEFAULT_DAYS_TO_EXPIRE = 180;
    let checkBannerCookie = $.cookie('cookie-shipto');

    var options = {
        type: 'popup',
        responsive: true,
        innerScroll: true,
        modalClass: 'm-shipto-modal',
        buttons: ({
            text: $.mage.__('Continue'),
            class: 'a-btn a-btn--primary',
            click: function () {
                let date = new Date();
                // use days param if set in init, otherwise use default days (180)
                let numberOfDays = DEFAULT_DAYS_TO_EXPIRE;
                date.setTime(date.getTime() + (numberOfDays*60*60*24*1000));
                let expires = "; expires=" + date.toUTCString();
                document.cookie = 'cookie-shipto' + "=" + true  + expires + "; path=/";

                let selected_state = $("#state :selected").text();
                // jQuery.ajax({
                //     url: "/vendor/module/result/result",
                //     type: "POST",
                //     data: {height:height,weight:weight},
                //     success: function(response){
                //         console.log(response);
                //     }
                // });

                //close the modal

    var popup = modal(options, $('#vistar-shipto-modal'));

    $(document).ready(function() {
        if (!checkBannerCookie) {
            setTimeout(function() {
            }, 2000);

My question is how can I pass this $("#state :selected").text() to controller so I can add some logic to it?

struct – SwiftUI – Cannot Pass Tuples into List View

I have an app whose UI was built with StoryBoard, that I’m now trying to convert to SwiftUI. The problem I’m having is that the app consists largely of arrays of Tuple data that is passed through Tableviews. In SwiftUI, however, I can’t find a way to pass tuple data into the list view. I keep getting the following error message:

Type ‘(String, String, String)’ cannot conform to ‘Hashable’; only
struct/enum/class types can conform to protocols.

I tried passing my tuple arrays through structs to see if I could get it to work that way, but was unable to effectively decode the tuple arrays through the structs. Anyone have any ideas? My code presently is as follows:

struct Result: View {
    let tupleArray = (("a", "z", "c"), ("e", "x", "d"), ("c", "y", "x"))

    var body: some View {
        NavigationView {
            List {
                ForEach(self.tupleArray, id: .self) { item in
                    ResultsRowView(text0: item.0, text1: item.1, text2: item.2)

My List Row View is as follows:

struct ResultsRowView: View {
    var text0 = "a"
    var text1 = "b"
    var text2 = "c"
    var body: some View {
        HStack(alignment: .center) {
        } //:HSTACK

france – Is it dangerous to go to Île de Noirmoutier using the pass?

Is this dangerous to cross?

As you can see on Wikipedia, fatalities are very rare, fewer than one every few years. gives some tips to avoid sinking your car and some current information (tide, weather, etc.).

Keep in mind that the area is very flat: as a result, if the tide is going up and that you see some water coming and/or you see many more cars exiting the pass than entering it, double-check the tide times. If the weather is already on the road, unless you are extremely sure about yourself, don’t enter the road.

There are two possibilities to get to the island of Noirmoutier

You can also take a boat, e.g. Pornic-Noirmoutier, windsurf to it, or even swim if good swimmer. Not that far from mainland.

c# – How to pass values of selected checboxes to controller

I can’t pass the values fro my view to controller i tried some of methods but nothing works fine for me.
I have one input field but on my web app when admin access to that page, only admin can select boxes for every employee, my last update was, I can made to do select only one by one checkbox, but when I try with jQuery or something else that doesn’t work.
Here is my cshtml.

    <table class="table table-striped grid-table" id="tableLabel">
                <button type="button" class="checkall" onClick="checkAll()">select/deselect</button>

@foreach (var item in (IEnumerable<cit.Models.getCheIdTip_Result>)Model)
                 <div class="pure-checkbox">
                 <input type="checkbox" idtip="@item.idtip" class="checktip" 
                 checked="@(item.idemployee == ViewBag.idemployee ? true : false)"
                 name="" id="" />
                 <label for=""></label>
    <input type="hidden" value="@ViewData("idemployee")" name="idemployee" id="idemployee" class="idemployee" />

This is js code below, I successfully select all of the boxes but when I try to pass values to controller with form collection nothing happen, or when I need to click to sellect all I open inspect element and go to section network to try catch some error or something, so there is also nothing on click event.

        var isChecked = false;
function checkAll() {
    var checkboxes = document.getElementsByTagName('input');
    if (isChecked) {
        for (var i = 0; i < checkboxes.length; i++) {
            if (checkboxes(i).className == 'checktip') {
                checkboxes(i).checked = true;
    } else {
        for (var i = 0; i < checkboxes.length; i++) {
            if (checkboxes(i).className == 'checktip') {
                checkboxes(i).checked = false;
    isChecked = !isChecked;

Is there any solution or function to resolve this problem?

theming – pass twig variable in drupal_entity() in drupal 8

The first assumption is that you already installed twig tweak module.

I believe the problem is in getting the form_name part, not in rendering.
first solution :

{% set form_name = node.field_c.0.value|trim|striptags %}
{{ drupal_entity('webform', form_name) }}

so if your field is a single value
I would suggest use twig field value module. then you can easily use

{% set form_name = content.field_c| field_value %}
{{ drupal_entity('webform', form_name) }}

another solution is :

{% set form_name = content.field_c| field_value %}
{{ { '#type': 'webform', '#webform': form_name } }}