So yeah. Parse order. I take it you've seen this pdf. If not, take a look, study it well.

What you need is for the opening tag to be in order before you hit stage 5: the parsing of module/plugin tags. In order to do that, you can only use simple conditionals in combination with early parsed global variables and preload replace variables. Native early parsed vars are limited, so go and get the super useful (and free) Mo' Variables to get more useful early parsed stuff.

Once installed, you can use {if paginated}{/if} as a simple conditional. Just beware you don't use any AND or OR operators, nor use {if:else} in your conditionals, because that will turn it into an advanced one, and will be parsed too late for your use.

First of all, this: {if {segment_2} == ''} is an advanced conditional. The simple syntax is {if segment_2 == ''}. Using tags in conditionals, like you do with the {exp:segment_search} tag, means the conditional is advanced, too. So, avoid.

Here's my take, using preload replace vars and simple conditionals only.

{!-- Don't set the query param if there is no query --}
{if segment_2 == ''}
    {preload_replace:pre_query=''}
{/if}

{!-- Don't set the query param for non-query paginated pages --}
{if segment_3 == ''}
    {if paginated}
        {preload_replace:pre_query=''}
    {/if}
{/if}

{!-- Determine group ID based on segment 1 --}
{if segment_1 == 'foo'}
    {preload_replace:pre_group_id="6"}
{/if}

{if segment_1 == 'bar'}
    {preload_replace:pre_group_id="7"}
{/if}

{!-- Default Preload Replace vars --}
{preload_replace:pre_query='query="{segment_2}"'}
{preload_replace:pre_group_id="6|7"}

{!-- Here comes the Results tag --}
{exp:low_search:results {pre_query} group_id="{pre_group_id}" limit="4"}
  ...
{/exp:low_search:results}


So, note that I don't use any conditionals in the tag itself. Everything is done using simple conditionals and preload replace vars. Keeps things nice and clean. And I haven't even mentioned Switchee yet...

Using conditionals to set tag parameters
I made a custom module wich sends a email now i want to edit the module so that it automatically uses one of the store email adresses i saw something like Mage::app()-&gt;getStore()-&gt; but i dont know how to use this to get store mailadress
I use zend 

    $mail = new Zend_Mail();        
    $mail-&gt;setBodyText($bericht);
    $mail-&gt;setFrom($email, $name);
    $mail-&gt;addTo("admin@magento.com", "sales manager");
    $mail-&gt;setSubject("Snel offerte");
    $tmpFilePath = $_FILES['foto']['tmp_name'];
    if ($tmpFilePath != ""){
        $file_size = $_FILES['foto']['size'];
        if (($file_size &gt; 22020096)){
            Mage::getSingleton('core/session')-&gt;addError($this-&gt;__('Bestand mag niet groter zijn dan 21 MB'));  
        }
        else{
            $fname = $_FILES['foto']['name'];
            $ftempname = $_FILES['foto']['tmp_name'];                   
            $at = new Zend_Mime_Part(file_get_contents($tmpFilePath));
            $at-&gt;disposition = Zend_Mime::DISPOSITION_INLINE;
            $at-&gt;encoding = Zend_Mime::ENCODING_BASE64;
            $at-&gt;filename = $fname;             
            $mail-&gt;addAttachment($at);
        }
    }
    try {
        $mail-&gt;send();

    }

