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:

var/www/html/magento/stores/store2/index.php

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');
$bootstrap->run($app);

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.

Thanks!

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.

Works:

{{ 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) }},  

etc.

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:

Learningetcmodule.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Learning_ShiptoModal">
        <sequence>
            <module name="Magento_Theme"/>
        </sequence>
    </module>
</config>

Learning/view/frontend/layout/default.xml

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

Learning/view/frontend/templates/shipto-prompt.phtml

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

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

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

Learning/view/frontend/web/requirejs-config.js

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

Learning/view/frontend/web/js/shipto-modal.js

require((
    'jquery',
    'Magento_Ui/js/modal/modal',
    'jquery/jquery.cookie',
    'domReady!'
),
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
                this.closeModal();
            }
        })
    };

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

    $(document).ready(function() {
        if (!checkBannerCookie) {
            $(this).find('(value="58")').remove();
            setTimeout(function() {
                $('#vistar-shipto-modal').modal('openModal');
            }, 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)
                }
            }//:LOOP
        }
    }
} 

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) {
            Text(text0)
            Text(text1)
            Text(text2)
        } //: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. https://www.passagedugois.com/crbst_3.html 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">
        <tr>
            <th>Name</th>
            <th>Book</th>
            <th>
                <button type="button" class="checkall" onClick="checkAll()">select/deselect</button>
            </th>

        </tr>
@foreach (var item in (IEnumerable<cit.Models.getCheIdTip_Result>)Model)
        {
            <tr>
                <td>@item.idtip</td>
                <td>@item.tipname</td>
                <td>
                 <div class="pure-checkbox">
                 <input type="checkbox" idtip="@item.idtip" class="checktip" 
                 checked="@(item.idemployee == ViewBag.idemployee ? true : false)"
                 name="@item.id.ToString()" id="@item.id.ToString()" />
                 <label for="@item.id.ToString()"></label>
                </div>
                </td>
            </tr>
        }
    </table>
    <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++) {
            console.log(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 } }}