terminal42 / contao-inserttags

This is a Contao Open Source CMS extension which allows you to define your own insert tags in the back end.
https://www.terminal42.ch
MIT License
10 stars 7 forks source link

Abfrage funktioniert nicht #3

Closed zonky2 closed 10 years ago

zonky2 commented 11 years ago

ich will eine Abfrage zum aktuellen Wochentag durchführen - die will nicht :-(

Folgende Einstellunegn:

Bedingung: Typ: Text Formel: Gleich Abfrage: {{date::D}} Wert: Do

habe es auch probiert mit:

Abfrage: {{date::N}} Wert: 4

und

Typ: SQL Formel: Gleich Abfrage: SELECT DAYOFWEEK(CURDATE()) Wert: 5

siehe https://community.contao.org/de/showthread.php?44493-inserttags-Abfrage-funktioniert-nicht

zonky2 commented 11 years ago

erster Teilerfolg: das DB-Statement funktioniert!

die Klammern wurden umgewandelt daher muss der Code wie folgt aussehen:

_code

        switch( $arrRow['conditionType'] )
        {
            case 'database':
                try
                {
                    // For some reason, = is escaped in the string!
                    $query = trim(str_replace('=', '=', $query));
                    $query = trim(str_replace('(', '(', $query));
                    $query = trim(str_replace(')', ')', $query));

                    $query = $this->Database->prepare($query)->execute()->fetchRow();

                    $query = $query[0];
                }

                // Something went wrong with the database query. Use as text instead
                catch(Exception $e)
                {
                    $query = $this->replaceInsertTags($arrRow['conditionQuery']);
                    //print_r($this->Database->prepare($query));
                }
                break;
        }

_code

weiterhin habe ich festgestellt, dass der "Tag" {{date::D}} per $this->replaceInsertTags nicht umgewandelt wird - andere tags funktionieren...??

zonky2 commented 11 years ago

die Ersetzung für {{date::*}} muss mit "false" erfolgen

Code:

    if ($arrRow['useCondition'])
    {
        $query = $this->replaceInsertTags($arrRow['conditionQuery'], false);

        switch( $arrRow['conditionType'] )
        {
            case 'database':
                try
                {
                    // For some reason, = is escaped in the string!
                    $query = trim(str_replace('=', '=', $query));
                    $query = trim(str_replace('(', '(', $query));
                    $query = trim(str_replace(')', ')', $query));

                    $query = $this->Database->prepare($query)->execute()->fetchRow();

                    $query = $query[0];
                }

                // Something went wrong with the database query. Use as text instead
                catch(Exception $e)
                {
                    $query = $this->replaceInsertTags($arrRow['conditionQuery'], false);
                }
                break;
        }
        //echo "query2: ".$query."<br>";        
        switch( $arrRow['conditionFormula'] )
        {
zonky2 commented 11 years ago

Hallo Andreas,

kommt das

irgendwann in das Tool? ich muss bei jedem Update die Datei wieder überschreiben...