K
K
karl12342022-02-01 23:52:54
PHP
karl1234, 2022-02-01 23:52:54

How to display another city in modx ???

Hello everyone, not long ago I started learning modx and php and I ran into such a problem here is the site https://rentacars.kz/ I need to bring another city there there is Almaty, Nur-sultan, and I still need Shimkent.

What I did:
1. Created a copy of the Nur-Sultan page, changed it, sort of connected the chunks I needed, but I need to display both the city and the header in the filter.
2. I started to figure it out and see what I need to add the conditions to 2 snippets, I started trying to write in one, but I get an error and that's it, can anyone tell me ??

here you need to add the Shimkent conditions to the getCountry and getnotherCountry files, well, at least as I understand))

Here is the code that I tried to add and already an error:

<?php
if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'almata' || $_REQUEST['q'] == 'nur-sultan/' || $_REQUEST['q'] == 'shymkent/'){
    if($langRu == 'true'){
        if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'nur-sultan/' || $_REQUEST['q'] == 'shymkent/'){
            echo 'Нур-Султан';
        }else if{
            echo 'Алматы';
        }else{
            echo 'Шимкент'
        }
    }else{
        echo str_replace('/', '', $_REQUEST['q']);
    }
}else{
    if($langRu == 'true'){
        echo 'Алматы';
    }elseif{
        echo 'almaty';
    }else{
        echo 'Шимкент';
    }
    
}
if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'nur-sultan/'){
    setcookie('city','astana');
}else if($_REQUEST['q'] == '' || $_REQUEST['q'] == '/'){
    setcookie('city','almaty');
}


Here is the file where you also need to add Shymkent, but I have not written yet))

<?php
if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'almaty' || $_REQUEST['q'] == 'nur-sultan/' || $_REQUEST['q'] == 'almaty/' || $_REQUEST['q'] == 'almaty/'){
    
        if(($_REQUEST['cultureKey'] == 'ru' || $_REQUEST['cultureKey'] == '') && $isUrl != 'true'){
            if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'nur-sultan/'){
                return 'Алматы';
            }else{
                return 'Нур-Султан';
            }    
        }    
    
        if($_REQUEST['cultureKey'] == 'en' && $isUrl == 'true'){

                if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'nur-sultan/'){
                    return '';    
                }else{
                    return 'astana';
                }        
            
        }
        if($_REQUEST['cultureKey'] == 'en' && $isUrl !== 'true'){
            if($_REQUEST['q'] == 'astana' || $_REQUEST['q'] == 'nur-sultan/'){
                    return 'almaty';    
                }else{
                    return 'astana';
                }        
        }
        
}else{
    if(($_REQUEST['cultureKey'] == 'ru' || $_REQUEST['cultureKey'] == '') && $isUrl != 'true'){
        return 'Нур-Султан';
    }    
    if($_REQUEST['cultureKey'] == 'en' || $isUrl == 'true'){
        return 'astana';
    }   
}


Here is the page that I still have https://rentacars.kz/shymkent

Help please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Vasiliev, 2022-02-02
@amvasiljev

Option 1. https://modstore.pro/packages/ecommerce/cityfields
It's cheap and will solve your issues with displaying cities, however, filtering products is not its functionality.
Option 2
What you are trying to do resembles the implementation of a multilingual site with switching by contexts. In this case, it is not enough just to copy the page - you need to create a new context, and create your products in it.
Option 3
There is a way to put a minishop paired with msearch2 and then you can specify the city as an option. In this case, switching by city will filter the product within one context and one catalog. But mserch2 is paid and not very cheap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question