|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TakingSides Smarty Rookie
Joined: 11 Dec 2010 Posts: 30
|
Posted: Sat Dec 18, 2010 5:14 pm Post subject: Iteration Integration would be nice.. any one able to help? |
|
|
Hey guys.
I have a simple problem, but I have no idea on how to make this work.
I have the following PHP page...
Code: | <?php
class AjaxPage extends Api {
// ...removed unrequired code ...
public function get_calendar_eventsPage() {
if (is_null($this->session->getSession(Api::SESSION_NAME_CALENDAR)))
$this->session->setSession(Api::SESSION_NAME_CALENDAR, strftime('%F'));
$events = new CalendarIterator(null, null);
$this->smarty->assign('events', $events->getDataByDate($this->session->getSession(Api::SESSION_NAME_CALENDAR)));
$this->smarty->display('ajax.calendar_events');
}
// ...removed unrequired code ...
} |
The template code is....
Code: | {foreach from=$events item='event' name='evt'}
<div id="event-{$event->id}" class="calendar-event" style="{calendar_position date=$event->created start_date=$event->start end_date=$event->finish this_hour=$event->this_hour} z-index: {$smarty.foreach.evt.iteration}; {$event->getCategoryObject()->style->div}">
<span class="calendar-event-title" style=" {$event->getCategoryObject()->style->span}">{$event->subject|truncate:'38':'...':true}</span><br clear="all" />
<p class="calendar-event-overview">{$event->description|nl2br}</p>
</div>
{/foreach} |
The Problem is...
Code: | {$event->getCategoryObject()->style->span} |
The problem is when I get smarty to attempt to execute $event->getCategoryObject(), which is a method inside the
$event iterator object, this will create another iterator object instance returning another object. If you run this via the PHP, it works fine. just Smarty doesn't like the execution of chained objects :/
All I want is that Smarty allows the developer to implement iterator methods for object chaining.
Since 99% of my work is O.O.P object chaining is normally something that's used alot of the time.
--
ASH |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Dec 18, 2010 6:03 pm Post subject: |
|
|
Smarty3 does support object chaining |
|
Back to top |
|
TakingSides Smarty Rookie
Joined: 11 Dec 2010 Posts: 30
|
Posted: Sun Dec 19, 2010 1:25 pm Post subject: re: U.Tews |
|
|
Okay, so thanks for confirming object chaining does work. and Yes it does, however only when there is not fatal error inside the class im trying to return an instance of.
This is embarrassing for me so I wont elaborate on the small error causing this issue. But it works a charm.
Thanks again |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|