Skip to content

Tag {php} throws an error Malformed tag contents in ... #376

@camohub

Description

@camohub

Version: 3

Bug Description

I would like to use {php} macro with valid php code but I am getting error. Malformed tag contents in ...

Steps To Reproduce

            {php
                    $accessCssClass = 'btn-danger';
                    $accessText = '';

                    if ( $last_access ) {
                        $now = new \DateTime();
                        $to_time = $last_access->getTimestamp();
                        $from_time = $now->getTimestamp();
                        $minute = round(abs($to_time - $from_time) / 60, 2);

                        if ( $minute <= 20 ) {
                            $accessCssClass = 'btn-success';
                            $accessText = $presenter->translate("device.online", "Online");
                        }
                        else {
                            $accessCssClass = 'btn-warning';
                            $accessText = $presenter->translate("device.offline", "Offline");
                        }
                    }
                    else {
                        $accessText = $presenter->translate("device.never_connected", "Never connected");
                    }
            }
            <span class="btn btn-xs {$accessCssClass}">{$accessText}</span>

Possible Solution

The problem is with the second if else block. But I dont see any problem with the code inside.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions