magento2 – Filter collection with OR of AND condition

Try this

$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter((('attribute'=>'brand','eq'=>'Toyota'),('attribute'=>'color', 'eq'=>'Red')));

$collection->addAttributeToFilter((('attribute'=>'brand','eq'=>'Ford'),('attribute'=>'color', 'eq'=>'Blue')));

$collection->addAttributeToFilter((('attribute'=>'brand','eq'=>'BMW'),('attribute'=>'color', 'eq'=>'White')));

Please print this collection also to string. Use this command for printing collections
echo $collection->getSelect()->__toString();

Thanks
Vibhore

9 – How to add filter criteria by current date in views

I am using Drupal 9 and have a content type with a field “Publish until” (datetime).
I want to add a filter in views that it will compare the date in this field with current date.
I found a solution here for Drupal 8
Views filter criteria date field is greater than current date

However, my screen looks a bit different:
enter image description here

To be more specific, I don’t have a “Value type” which seems to be necessary in my case.
Am I missing any module that should be enabled?
Or is it related to the Drupal 9 itself?

If there is any another approach to solve this problem with filtering I will be glad to know it.

Service to filter out malformed emails for a mailing list?

Can anyone recommend a service to filter out malformed or non-existant emails from large mailing lists?

ie: Input a list of 50k emails fr… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1843362&goto=newpost

views – Contextual Filter Path Alias

I searched for this for some time now but couldnt find an anwser. I am using drupal 9.1.5 and pathauto. I have content types department and depratment news. The news are linked to the department. So whenever you create a department news you link it to a department. Now I want to display all depratment news linked to the department when i am on the department page (all children) and when I am on a page of a children (department news) I want to display all siblings, i.e. all departments news linked with the same department.

My url for departments is
(node:title)
and for department news is
(node:field_department:entity)/(node:title)

I thought that using a contextual filter in my view using the raw value from the url would work. So I used path component 1 and checked to use path alias. However this does not display anything.
enter image description here

When using path component 2 and disable to use path alias it works for the department news, which makes sence as I am internally on page node/xxx. I was so frustrated that I tried every other combination of path component and use path alias but nothing works. When using a fixed value for a department everything works as expected for that specific department

Do you filter languages in GSA SER?

Do you filter site languages/ search engines/ in Options? 

I have a folder of thousands of images. I want to filter it so that it only displays all the images where the width>height

In file explorer I can specify the exact width and the height in the search bar but all the images have vastly different dimensions.

power automate – Ms flow filter sql table with datetime field


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




web app – How to best place a “Filter” sheet in a webpage?

Consider the following page screen, that consists all conversations (left side) and the selected conversation display (middle of the screen; chat):

enter image description here

Now I would like to be able to filter the list of the conversations (that’s found on the left) by various options such as “Filter by classes” (there can be many of them), “New messages”, “Read but unanswered messages”, “Has Video, Has Files?” etc. But where would be the best place to put this filter sheet? The filter icon is already placed in at the top of the conversations that would enable the filter page.

I have outlined 4 possible options, however all have both good and bad sides:

enter image description here

A – Makes sense as it looks/feels like is filtering in the actual inbox. However, it hides the actual inbox, making it a bit unintuitive to see what you’re filtering for. Having a checkmark icon to confirm the filter would be a solution.

B – Material guidelines suggest to do it this way, to separate it form the navigation drawer on the left. However, in this chat looking design it looks more as if the Filter is related to the specific conversation, not total inbox.

C – okayish I suppose. We’re trying to avoid pop-ups if possible. But maybe it is a viable solution

D – Dropdown list next to the icon. This one’s tougher as it can’t be too large, but can provide difficulties when more options for filtering arise in the future.

What would you suggest? Perhaps another way completely?

python – Filter server names with specific permissions (Discord API)

I’m using the Discord API to get all the guilds the user is in. With the JSON response, I’m trying to filter out all the server names where the user has the manage_guild permission with list comprehension.

all_guild_names = (x('name') for x in guilds if int(x('permissions')) & 0x00000020 != 0)

I have this code but it returns an empty list. Does anyone know how to do this or how to do it in another way?

PHP strpos() as a way to implement an swear word filter

I wrote a short function that should check if user input does contain any bad words that I predefined inside $bad_words array. I don’t even care to replace them – I just want to ban if there are any. The code seems to work as it should – in the example below will detect the quoted string badword and the function does return true.

My question: Is this a good way to use foreach and strpos()? Perhaps there is better way to check if $input contains one of the $bad_words array elements? Or is it just fine as I wrote it?

function checkswearing($input)
{
    $input = preg_replace('/(^0-9^A-Z^a-z^-^ )/', '', $input);//clean, temporary $input that just contains pure text and numbers
    
    $bad_words = array('badword', 'reallybadword', 'some other bad words');//bad words array
    
    foreach($bad_words as $bad_word)
    {//so here I'm using a foreach loop with strpos() to check if $input contains one of the bad words or not
        if (strpos($input, $bad_word) !== false)
            return true;//if there is one - no reason to check further bad words
    }
    return false;//$input is clean!
}

$input = 'some input text, might contain a "badword" and I'd like to check if it does or not';

if (checkswearing($input))
    echo 'Oh dear, my ears!';
else
{
    echo 'You are so polite, so let's proceed with the rest of the code!';
    (...)
}