Skip to content

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

Closed

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.

Activity

  1. locked and limited conversation to collaborators on Sep 27, 2024
  2. converted this issue into a discussion #377 on Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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