Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If !empty - site.php not working #110

Open
Dejmienwp opened this issue Jun 17, 2021 · 2 comments
Open

If !empty - site.php not working #110

Dejmienwp opened this issue Jun 17, 2021 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@Dejmienwp
Copy link

Witam.
Mam pętle do wyświetlania wydarzeń. Niestety nie działa if !empty

{if: !empty($allEvents)}
{loop: $allEvents}
<div class="uk-flex uk-margin-small">
    <div class="">
		<div class="uk-text-light" style="background-color:#f08231;padding: 10px 15px;color:#fff;font-weight: 600;">{$value.dateday}</div>
	</div>
    <div class="uk-margin-small-left">
		<h5 class="uk-margin-remove" style="color:#f08231;">{$value.name}</h5>
		<p class="uk-margin-remove uk-text-small">{$value.dates} | <span>{$value.desc}</span></p>
	</div>
</div>
{/loop}
{else}
<div>
	Aktualnie brak wydarzeń na naszych obiektach.
</div>
{/if}

Site.php

   public function init()
    {
        $newDate = $this->core->db('events')->where('datestart', '<', date('Y-m-d H:i'))->update(
            [   
                'status' => 'unactive'
            ]);

        $this->tpl->set('allEvents', function () {
            return $this->_getAllEvents();
        });

        $this->tpl->set('events', function () {
            return ['form' => $this->_insertForm()];
        });
    }

    private function _insertForm()
    {
        return $this->draw('form.html');
    }

    public function _getAllEvents()
    {
        $rows = $this->db('events')->where('status', 'activ')->asc('datestart')->toArray();
        $result = [];        
   
        foreach ($rows as $row) {

            $row['dateday'] = date('d', strtotime($row['datestart']));
            $row['dates'] = (new \DateTime(date('d-m-Y H:i', strtotime($row['datestart']))))->format('Mx Y H:i');
            $keys = array_keys($this->core->lang['blog']);
            $vals = array_values($this->core->lang['blog']);
            $row['dates'] = str_replace($keys, $vals, strtolower($row['dates']));
            $result[] = $row;
        }  
        return $result; 
     }

Jakiś Pomysł jak to naprawić ? :/

@michu2k michu2k assigned michu2k and unassigned michu2k Jul 31, 2021
@michu2k michu2k added the help wanted Extra attention is needed label Jul 31, 2021
@Dejmienwp
Copy link
Author

Any Idea why {if: !empty()} not working on site? In /admin its good i wanna create event module when not active events i have any div "xxx "

@michu2k
Copy link
Collaborator

michu2k commented Aug 12, 2021

Hi @Dejmienwp
It is hard to say where is the problem. Have you tried to print $result in the form.html file? Maybe this variable is not passed to the view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants