related v snippet hlasi Call to a member function related() on a non-object
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- blueticket
- Člen | 41
Zdravim, mam nasledovni problem. Kdyz pouziju foreach pod snippetem (articlesComment), tak mi nette hlasi chybu Call to a member function related() on a non-object. Kdyz vsak ten foreach spustim mimo snippetu vse jede jak ma. Nevite mi poradit co delam spatne? Komentare bych totiz potreboval refreshovat pres AJAX.
{snippet articlesComment}
{foreach $row->related("tbl_comments","timeline_id") as $row_comments}
<div class="col-lg-12 col-md-12 col-xs-12" style="padding:5px 0px 5px 0px;border-top:#EDEBE4 1px solid;">
<img class="user-block-thumb" src="{DataModel::getProfileImage($row_comments->profile_id)}"/>
{var $linkurl = DataModel::getProfileLinkUrl($row_comments->profile_id)}
<span class="notification-item-header text-uppercase"><a n:href="$linkurl id=>$row_comments->profile_id" style="color:#a5987f;">{DataModel::getProfileName($row_comments->profile_id)}</a></span>
{if DataModel::getPermission($row_comments->id,$logged_in_id,8)}
<a style="position:absolute;right:10px;cursor:pointer;color:gray;font-size:13px;" data-toggle="tooltip" n:href="TimelineRemoveComment! id=>$row_comments->id" data-placement='top' title="{_ 'Delete'}"><i class="fa fa-times"></i></a>
{/if}
<span class="notification-item-event-time">{$row_comments->comment_date_time|date:'%d.%m.%Y'}| {$row_comments->comment_date_time|date:'H:i'}</span>
<span class="notification-item-event" style="color:black">{$row_comments->comment}</span>
</div>
{/foreach}
{/snippet}
Diky moc
- blueticket
- Člen | 41
Z presenteru posilam jenom $timeline_rows. Samotnej $row se bere z foreach.
Vypada to nejak takhle:
{foreach $timeline_rows as $row}
{snippet articlesComment}
{foreach $row->related("tbl_comments","timeline_id") as $row_comments}
<div class="col-lg-12 col-md-12 col-xs-12" style="padding:5px 0px 5px 0px;border-top:#EDEBE4 1px solid;">
<img class="user-block-thumb" src="{DataModel::getProfileImage($row_comments->profile_id)}"/>
{var $linkurl = DataModel::getProfileLinkUrl($row_comments->profile_id)}
<span class="notification-item-header text-uppercase"><a n:href="$linkurl id=>$row_comments->profile_id" style="color:#a5987f;">{DataModel::getProfileName($row_comments->profile_id)}</a></span>
{if DataModel::getPermission($row_comments->id,$logged_in_id,8)}
<a style="position:absolute;right:10px;cursor:pointer;color:gray;font-size:13px;" data-toggle="tooltip" n:href="TimelineRemoveComment! id=>$row_comments->id" data-placement='top' title="{_ 'Delete'}"><i class="fa fa-times"></i></a>
{/if}
<span class="notification-item-event-time">{$row_comments->comment_date_time|date:'%d.%m.%Y'}| {$row_comments->comment_date_time|date:'H:i'}</span>
<span class="notification-item-event" style="color:black">{$row_comments->comment}</span>
</div>
{/foreach}
{/snippet}
{/foreach}
Diky moc
- David Matějka
- Moderator | 6445
mozna hledas dynamicke snippety: https://doc.nette.org/…ication/ajax
takhle, jak to mas, by to nefungovalo – nette by nepoznalo, ktery snippet pro ktery row ma invalidovat
- blueticket
- Člen | 41
Diky moc, a prosim Te, nevis mi nahodou poradit, jak ten $row v snippetu naplnit? V dokumentaci to nejak nevidim :-(
Dekuji